opal 0.3.41 → 0.3.42
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +14 -1
- data/Gemfile +2 -5
- data/Rakefile +41 -3
- data/bin/opal +33 -0
- data/lib/opal.rb +2 -12
- data/lib/opal/core_ext.rb +5 -0
- data/lib/opal/grammar.rb +2207 -2138
- data/lib/opal/grammar.y +21 -0
- data/lib/opal/grammar_helpers.rb +360 -0
- data/lib/opal/lexer.rb +55 -401
- data/lib/opal/lexer_scope.rb +28 -0
- data/lib/opal/parser.rb +155 -171
- data/lib/opal/target_scope.rb +257 -0
- data/lib/opal/version.rb +1 -1
- data/opal.gemspec +6 -2
- data/opal/opal-parser.js.erb +3 -2
- data/opal/opal.rb +20 -18
- data/opal/opal/array.rb +21 -12
- data/opal/opal/basic_object.rb +2 -1
- data/opal/opal/boolean.rb +3 -0
- data/opal/opal/browser_loader.js +57 -0
- data/opal/opal/class.rb +51 -13
- data/opal/opal/date.rb +1 -20
- data/opal/opal/enumerable.rb +66 -33
- data/opal/opal/error.rb +2 -0
- data/opal/opal/hash.rb +1 -1
- data/opal/opal/kernel.rb +14 -3
- data/opal/opal/nil_class.rb +4 -0
- data/opal/opal/proc.rb +9 -1
- data/opal/opal/racc.rb +2 -2
- data/opal/opal/regexp.rb +1 -1
- data/opal/opal/runtime.js +14 -4
- data/opal/opal/string.rb +21 -4
- data/opal/opal/time.rb +27 -0
- data/spec/core/array/allocate_spec.rb +7 -1
- data/spec/core/array/append_spec.rb +18 -3
- data/spec/core/array/array_spec.rb +7 -0
- data/spec/core/array/assoc_spec.rb +23 -8
- data/spec/core/array/at_spec.rb +23 -3
- data/spec/core/array/choice_spec.rb +20 -0
- data/spec/core/array/clear_spec.rb +45 -4
- data/spec/core/array/combination_spec.rb +55 -0
- data/spec/core/array/compact_spec.rb +72 -1
- data/spec/core/array/constructor_spec.rb +13 -2
- data/spec/core/array/count_spec.rb +15 -7
- data/spec/core/array/delete_at_spec.rb +44 -1
- data/spec/core/array/delete_if_spec.rb +52 -2
- data/spec/core/array/delete_spec.rb +83 -2
- data/spec/core/array/drop_spec.rb +24 -16
- data/spec/core/array/drop_while_spec.rb +17 -0
- data/spec/core/array/each_index_spec.rb +11 -1
- data/spec/core/array/each_spec.rb +20 -2
- data/spec/core/array/empty_spec.rb +4 -1
- data/spec/core/array/eql_spec.rb +14 -0
- data/spec/core/array/fetch_spec.rb +31 -2
- data/spec/core/array/find_index_spec.rb +8 -0
- data/spec/core/array/first_spec.rb +45 -8
- data/spec/core/array/fixtures/classes.rb +538 -0
- data/spec/core/array/flatten_spec.rb +200 -7
- data/spec/core/array/frozen_spec.rb +32 -0
- data/spec/core/array/include_spec.rb +16 -1
- data/spec/core/array/index_spec.rb +5 -25
- data/spec/core/array/insert_spec.rb +37 -3
- data/spec/core/array/inspect_spec.rb +6 -12
- data/spec/core/array/intersection_spec.rb +55 -4
- data/spec/core/array/join_spec.rb +29 -4
- data/spec/core/array/keep_if_spec.rb +13 -6
- data/spec/core/array/last_spec.rb +35 -1
- data/spec/core/array/length_spec.rb +7 -4
- data/spec/core/array/map_spec.rb +9 -47
- data/spec/core/array/minus_spec.rb +68 -4
- data/spec/core/array/multiply_spec.rb +138 -6
- data/spec/core/array/new_spec.rb +92 -3
- data/spec/core/array/ntimes_spec.rb +26 -0
- data/spec/core/array/plus_spec.rb +48 -2
- data/spec/core/array/pop_spec.rb +159 -39
- data/spec/core/array/push_spec.rb +29 -1
- data/spec/core/array/rassoc_spec.rb +31 -2
- data/spec/core/array/reject_spec.rb +89 -2
- data/spec/core/array/replace_spec.rb +7 -29
- data/spec/core/array/reverse_each_spec.rb +25 -1
- data/spec/core/array/reverse_spec.rb +53 -1
- data/spec/core/array/rindex_spec.rb +55 -5
- data/spec/core/array/select_spec.rb +35 -8
- data/spec/core/array/shared/collect.rb +0 -0
- data/spec/core/array/shared/enumeratorize.rb +12 -0
- data/spec/core/array/shared/eql.rb +95 -0
- data/spec/core/array/shared/index.rb +37 -0
- data/spec/core/array/shared/inspect.rb +3 -0
- data/spec/core/array/shared/join.rb +7 -0
- data/spec/core/array/shared/keep_if.rb +0 -0
- data/spec/core/array/shared/length.rb +0 -0
- data/spec/core/array/shared/replace.rb +0 -0
- data/spec/core/array/shared/slice.rb +0 -0
- data/spec/core/array/shift_spec.rb +132 -23
- data/spec/core/array/shuffle_spec.rb +82 -6
- data/spec/core/array/size_spec.rb +7 -4
- data/spec/core/array/slice_spec.rb +132 -1
- data/spec/core/array/sort_spec.rb +263 -14
- data/spec/core/array/take_spec.rb +24 -16
- data/spec/core/array/take_while_spec.rb +14 -10
- data/spec/core/array/to_a_spec.rb +18 -1
- data/spec/core/array/to_ary_spec.rb +15 -1
- data/spec/core/array/try_convert_spec.rb +39 -2
- data/spec/core/array/uniq_spec.rb +148 -3
- data/spec/core/array/unshift_spec.rb +36 -1
- data/spec/core/array/zip_spec.rb +36 -1
- data/spec/core/class/new_spec.rb +8 -6
- data/spec/core/enumerable/all_spec.rb +37 -9
- data/spec/core/enumerable/any_spec.rb +45 -7
- data/spec/core/enumerable/collect_spec.rb +4 -1
- data/spec/core/enumerable/count_spec.rb +4 -1
- data/spec/core/enumerable/detect_spec.rb +2 -2
- data/spec/core/enumerable/drop_spec.rb +4 -1
- data/spec/core/enumerable/drop_while_spec.rb +4 -1
- data/spec/core/enumerable/each_slice_spec.rb +2 -1
- data/spec/core/enumerable/each_with_index_spec.rb +4 -1
- data/spec/core/enumerable/each_with_object_spec.rb +4 -1
- data/spec/core/enumerable/entries_spec.rb +4 -1
- data/spec/core/enumerable/find_all_spec.rb +4 -1
- data/spec/core/enumerable/find_index_spec.rb +4 -1
- data/spec/core/enumerable/find_spec.rb +5 -2
- data/spec/core/enumerable/first_spec.rb +4 -1
- data/spec/core/enumerable/fixtures/classes.rb +198 -2
- data/spec/core/enumerable/grep_spec.rb +4 -1
- data/spec/core/enumerable/take_spec.rb +4 -1
- data/spec/core/enumerable/to_a_spec.rb +4 -1
- data/spec/core/false/and_spec.rb +11 -0
- data/spec/core/false/inspect_spec.rb +7 -0
- data/spec/core/false/or_spec.rb +11 -0
- data/spec/core/false/to_s_spec.rb +7 -0
- data/spec/core/false/xor_spec.rb +11 -0
- data/spec/core/kernel/rand_spec.rb +5 -5
- data/spec/core/module/const_get_spec.rb +4 -4
- data/spec/core/module/fixtures/classes.rb +434 -0
- data/spec/core/module/method_defined_spec.rb +49 -0
- data/spec/core/module/module_function_spec.rb +28 -0
- data/spec/core/nil/and_spec.rb +3 -1
- data/spec/core/nil/dup_spec.rb +7 -0
- data/spec/core/nil/inspect_spec.rb +3 -1
- data/spec/core/nil/nil_spec.rb +3 -1
- data/spec/core/nil/or_spec.rb +4 -2
- data/spec/core/nil/to_a_spec.rb +3 -1
- data/spec/core/nil/to_f_spec.rb +3 -1
- data/spec/core/nil/to_i_spec.rb +3 -1
- data/spec/core/nil/to_s_spec.rb +3 -1
- data/spec/core/nil/xor_spec.rb +4 -2
- data/spec/core/string/element_reference_spec.rb +14 -1
- data/spec/core/string/fixtures/classes.rb +0 -0
- data/spec/core/true/and_spec.rb +11 -0
- data/spec/core/true/inspect_spec.rb +7 -0
- data/spec/core/true/or_spec.rb +11 -0
- data/spec/core/true/to_s_spec.rb +7 -0
- data/spec/core/true/xor_spec.rb +11 -0
- data/spec/{core → core_ext}/array/element_reference_spec.rb +0 -0
- data/spec/{core → core_ext}/array/equal_value_spec.rb +0 -0
- data/spec/{core → core_ext}/array/fill_spec.rb +0 -0
- data/spec/{core → core_ext}/array/reduce_spec.rb +0 -0
- data/spec/core_ext/basic_object/send_spec.rb +3 -3
- data/spec/{core → core_ext}/boolean/singleton_class_spec.rb +0 -0
- data/spec/{core → core_ext}/boolean/to_json_spec.rb +0 -0
- data/spec/core_ext/class/_inherited_spec.rb +3 -3
- data/spec/core_ext/class/proc_methods_spec.rb +2 -2
- data/spec/core_ext/class/singleton_methods_spec.rb +8 -8
- data/spec/core_ext/method_missing_spec.rb +3 -3
- data/spec/core_ext/native/method_missing_spec.rb +3 -2
- data/spec/core_ext/native/to_native_spec.rb +3 -2
- data/spec/{core → core_ext}/nil/to_json_spec.rb +0 -0
- data/spec/date.rb +0 -0
- data/spec/fileutils.rb +0 -0
- data/spec/filters/ancestors.rb +4 -0
- data/spec/filters/array_delete.rb +3 -0
- data/spec/filters/array_fetch.rb +3 -0
- data/spec/filters/array_first.rb +3 -0
- data/spec/filters/array_flatten.rb +14 -0
- data/spec/filters/array_intersection.rb +5 -0
- data/spec/filters/array_join.rb +6 -0
- data/spec/filters/array_subclasses.rb +4 -0
- data/spec/filters/block_args.rb +3 -0
- data/spec/filters/coerce_integer.rb +9 -0
- data/spec/filters/frozen.rb +4 -0
- data/spec/filters/mocks.rb +3 -0
- data/spec/filters/should_receive.rb +4 -0
- data/spec/filters/tainted.rb +7 -0
- data/spec/fixtures/class.rb +124 -0
- data/spec/fixtures/class_variables.rb +0 -0
- data/spec/fixtures/constants.rb +0 -0
- data/spec/grammar/alias_spec.rb +1 -1
- data/spec/grammar/def_spec.rb +1 -0
- data/spec/grammar/lvar_spec.rb +1 -2
- data/spec/grammar/nth_ref_spec.rb +13 -0
- data/spec/grammar/sclass_spec.rb +6 -7
- data/spec/grammar/str_spec.rb +4 -4
- data/spec/grammar/string_spec.rb +8 -0
- data/spec/grammar/xstr_spec.rb +4 -4
- data/spec/iconv.rb +0 -0
- data/spec/language/alias_spec.rb +140 -3
- data/spec/language/and_spec.rb +14 -7
- data/spec/language/array_spec.rb +57 -5
- data/spec/language/block_spec.rb +466 -49
- data/spec/language/break_spec.rb +294 -44
- data/spec/language/case_spec.rb +151 -3
- data/spec/language/class_spec.rb +196 -0
- data/spec/language/class_variable_spec.rb +56 -0
- data/spec/language/def_spec.rb +507 -4
- data/spec/language/defined_spec.rb +19 -7
- data/spec/language/ensure_spec.rb +26 -39
- data/spec/language/execution_spec.rb +15 -0
- data/spec/language/fixtures/array.rb +11 -0
- data/spec/language/fixtures/block.rb +57 -0
- data/spec/language/fixtures/break.rb +240 -0
- data/spec/language/fixtures/ensure.rb +72 -0
- data/spec/language/fixtures/literal_lambda.rb +7 -0
- data/spec/language/fixtures/metaclass.rb +33 -0
- data/spec/language/fixtures/module.rb +24 -0
- data/spec/language/fixtures/next.rb +78 -12
- data/spec/language/fixtures/return.rb +118 -0
- data/spec/language/fixtures/send.rb +110 -0
- data/spec/language/fixtures/send_1.9.rb +22 -0
- data/spec/language/fixtures/super.rb +308 -0
- data/spec/language/fixtures/variables.rb +58 -0
- data/spec/language/fixtures/yield.rb +5 -0
- data/spec/language/for_spec.rb +192 -0
- data/spec/language/hash_spec.rb +29 -5
- data/spec/language/if_spec.rb +90 -9
- data/spec/language/literal_lambda_spec.rb +1 -47
- data/spec/language/loop_spec.rb +39 -2
- data/spec/language/metaclass_spec.rb +151 -5
- data/spec/language/module_spec.rb +56 -0
- data/spec/language/next_spec.rb +370 -12
- data/spec/language/not_spec.rb +55 -0
- data/spec/language/numbers_spec.rb +56 -0
- data/spec/language/or_spec.rb +31 -3
- data/spec/language/order_spec.rb +79 -0
- data/spec/language/precedence_spec.rb +483 -0
- data/spec/language/proc_spec.rb +249 -21
- data/spec/language/redo_spec.rb +67 -0
- data/spec/language/rescue_spec.rb +121 -0
- data/spec/language/retry_spec.rb +56 -0
- data/spec/language/return_spec.rb +281 -0
- data/spec/language/send_spec.rb +141 -48
- data/spec/language/singleton_class_spec.rb +1 -1
- data/spec/language/string_spec.rb +11 -0
- data/spec/language/super_spec.rb +213 -133
- data/spec/language/symbol_spec.rb +2 -1
- data/spec/language/undef_spec.rb +3 -1
- data/spec/language/unless_spec.rb +6 -2
- data/spec/language/until_spec.rb +102 -3
- data/spec/language/variables_spec.rb +1212 -16
- data/spec/language/versions/array_1.9.rb +39 -0
- data/spec/language/versions/case_1.9.rb +20 -0
- data/spec/language/versions/hash_1.9.rb +18 -0
- data/spec/language/versions/literal_lambda_1.9.rb +143 -0
- data/spec/language/versions/not_1.9.rb +22 -0
- data/spec/language/versions/send_1.9.rb +241 -0
- data/spec/language/versions/symbol_1.9.rb +15 -0
- data/spec/language/versions/variables_1.9.rb +8 -0
- data/spec/language/while_spec.rb +70 -5
- data/spec/language/yield_spec.rb +32 -6
- data/spec/mspec/guards/block_device.rb +0 -0
- data/spec/mspec/guards/endian.rb +0 -0
- data/spec/mspec/helpers/environment.rb +0 -0
- data/spec/mspec/helpers/language_version.rb +0 -0
- data/spec/mspec/helpers/tmp.rb +0 -0
- data/spec/ospec/filter.rb +32 -0
- data/spec/ospec/main.rb.erb +18 -0
- data/spec/ospec/phantom.rb +97 -0
- data/spec/ospec/runner.rb +95 -0
- data/spec/ospec/sprockets.js +40 -0
- data/spec/pp.rb +3 -0
- data/spec/rbconfig.rb +5 -0
- data/spec/spec_helper.rb +53 -26
- data/spec/yaml.rb +0 -0
- metadata +275 -31
- data/config.ru +0 -8
- data/lib/opal/processor.rb +0 -47
- data/lib/opal/scope.rb +0 -236
- data/lib/opal/server.rb +0 -94
- data/spec/core/boolean/and_spec.rb +0 -17
- data/spec/core/boolean/inspect_spec.rb +0 -9
- data/spec/core/boolean/or_spec.rb +0 -17
- data/spec/core/boolean/to_s_spec.rb +0 -9
- data/spec/core/boolean/xor_spec.rb +0 -17
data/opal/opal/class.rb
CHANGED
@@ -96,14 +96,18 @@ class Class
|
|
96
96
|
|
97
97
|
def attr_reader(*names)
|
98
98
|
%x{
|
99
|
-
var proto = #{self}.prototype;
|
99
|
+
var proto = #{self}.prototype, cls = #{self};
|
100
100
|
for (var i = 0, length = names.length; i < length; i++) {
|
101
101
|
(function(name) {
|
102
102
|
proto[name] = nil;
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
103
|
+
var func = function() { return this[name] };
|
104
|
+
|
105
|
+
if (cls._isSingleton) {
|
106
|
+
proto._defs('$' + name, func);
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
proto['$' + name] = func;
|
110
|
+
}
|
107
111
|
})(names[i]);
|
108
112
|
}
|
109
113
|
}
|
@@ -113,14 +117,18 @@ class Class
|
|
113
117
|
|
114
118
|
def attr_writer(*names)
|
115
119
|
%x{
|
116
|
-
var proto = #{self}.prototype;
|
120
|
+
var proto = #{self}.prototype, cls = #{self};
|
117
121
|
for (var i = 0, length = names.length; i < length; i++) {
|
118
122
|
(function(name) {
|
119
123
|
proto[name] = nil;
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
+
var func = function(value) { return this[name] = value; };
|
125
|
+
|
126
|
+
if (cls._isSingleton) {
|
127
|
+
proto._defs('$' + name + '=', func);
|
128
|
+
}
|
129
|
+
else {
|
130
|
+
proto['$' + name + '='] = func;
|
131
|
+
}
|
124
132
|
})(names[i]);
|
125
133
|
}
|
126
134
|
}
|
@@ -129,6 +137,10 @@ class Class
|
|
129
137
|
|
130
138
|
alias attr attr_accessor
|
131
139
|
|
140
|
+
def const_defined?(name)
|
141
|
+
`!!(#{self}._scope[#{name}])`
|
142
|
+
end
|
143
|
+
|
132
144
|
def const_get(name)
|
133
145
|
%x{
|
134
146
|
var result = #{self}._scope[name];
|
@@ -155,8 +167,12 @@ class Class
|
|
155
167
|
}
|
156
168
|
end
|
157
169
|
|
158
|
-
def define_method(name, &block)
|
170
|
+
def define_method(name, method = undefined, &block)
|
159
171
|
%x{
|
172
|
+
if (method) {
|
173
|
+
block = method;
|
174
|
+
}
|
175
|
+
|
160
176
|
if (block === nil) {
|
161
177
|
no_block_given();
|
162
178
|
}
|
@@ -234,16 +250,38 @@ class Class
|
|
234
250
|
|
235
251
|
alias class_eval module_eval
|
236
252
|
|
253
|
+
def method_defined?(method)
|
254
|
+
%x{
|
255
|
+
if (typeof(#{self}.prototype['$' + method]) === 'function') {
|
256
|
+
return true;
|
257
|
+
}
|
258
|
+
|
259
|
+
return false;
|
260
|
+
}
|
261
|
+
end
|
262
|
+
|
263
|
+
def module_function(*methods)
|
264
|
+
%x{
|
265
|
+
for (var i = 0, length = methods.length; i < length; i++) {
|
266
|
+
var meth = methods[i], func = #{self}.prototype['$' + meth];
|
267
|
+
|
268
|
+
#{self}['$' + meth] = func;
|
269
|
+
}
|
270
|
+
|
271
|
+
return #{self};
|
272
|
+
}
|
273
|
+
end
|
274
|
+
|
237
275
|
def name
|
238
276
|
`#{self}._name`
|
239
277
|
end
|
240
278
|
|
241
|
-
def new(*)
|
279
|
+
def new(*args, &block)
|
242
280
|
%x{
|
243
|
-
var args = __slice.call(arguments);
|
244
281
|
var obj = new #{self};
|
245
282
|
obj._id = Opal.uid();
|
246
283
|
|
284
|
+
obj.$initialize._p = block;
|
247
285
|
obj.$initialize.apply(obj, args);
|
248
286
|
return obj;
|
249
287
|
}
|
data/opal/opal/date.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
native_date = `Date`
|
2
2
|
|
3
|
-
days_of_week = %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday]
|
4
|
-
short_days = %w[Sun Mon Tue Wed Thu Fri Sat]
|
5
|
-
short_months = %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec]
|
6
|
-
long_months = %w[January Febuary March April May June July August September October November December]
|
7
|
-
|
8
3
|
class Date
|
9
4
|
def self.wrap(native)
|
10
5
|
instance = allocate
|
@@ -114,21 +109,7 @@ class Date
|
|
114
109
|
end
|
115
110
|
|
116
111
|
def strftime(format = '')
|
117
|
-
|
118
|
-
var d = #{self}._date;
|
119
|
-
|
120
|
-
return format.replace(/%(-?.)/g, function(full, m) {
|
121
|
-
switch (m) {
|
122
|
-
case 'a': return short_days[d.getDay()];
|
123
|
-
case 'A': return days_of_week[d.getDay()];
|
124
|
-
case 'b': return short_months[d.getMonth()];
|
125
|
-
case 'B': return long_months[d.getMonth()];
|
126
|
-
case '-d': return d.getDate();
|
127
|
-
case 'Y': return d.getFullYear();
|
128
|
-
default: return m ;
|
129
|
-
}
|
130
|
-
});
|
131
|
-
}
|
112
|
+
`#{self}._date.$strftime(#{format})`
|
132
113
|
end
|
133
114
|
|
134
115
|
def to_s
|
data/opal/opal/enumerable.rb
CHANGED
@@ -6,11 +6,15 @@ module Enumerable
|
|
6
6
|
if (block !== nil) {
|
7
7
|
proc = function(obj) {
|
8
8
|
var value;
|
9
|
-
|
10
|
-
|
9
|
+
var args = [];
|
10
|
+
for(var i = 0; i < arguments.length; i ++) {
|
11
|
+
args[i] = arguments[i];
|
12
|
+
}
|
13
|
+
|
14
|
+
if ((value = block.apply(#{self}, args)) === __breaker) {
|
11
15
|
return __breaker.$v;
|
12
16
|
}
|
13
|
-
|
17
|
+
|
14
18
|
if (value === false || value === nil) {
|
15
19
|
result = false;
|
16
20
|
__breaker.$v = nil;
|
@@ -21,7 +25,7 @@ module Enumerable
|
|
21
25
|
}
|
22
26
|
else {
|
23
27
|
proc = function(obj) {
|
24
|
-
if (obj === false || obj === nil) {
|
28
|
+
if ((obj === false || obj === nil) && arguments.length < 2) {
|
25
29
|
result = false;
|
26
30
|
__breaker.$v = nil;
|
27
31
|
|
@@ -30,21 +34,26 @@ module Enumerable
|
|
30
34
|
}
|
31
35
|
}
|
32
36
|
|
33
|
-
#{self}.$each
|
37
|
+
#{self}.$each._p = proc;
|
38
|
+
#{self}.$each();
|
34
39
|
|
35
40
|
return result;
|
36
41
|
}
|
37
42
|
end
|
38
43
|
|
39
|
-
def any?(&block)
|
44
|
+
def any?(&block)
|
40
45
|
%x{
|
41
46
|
var result = false, proc;
|
42
47
|
|
43
48
|
if (block !== nil) {
|
44
49
|
proc = function(obj) {
|
45
50
|
var value;
|
46
|
-
|
47
|
-
|
51
|
+
var args = [];
|
52
|
+
for(var i = 0; i < arguments.length; i ++) {
|
53
|
+
args[i] = arguments[i];
|
54
|
+
}
|
55
|
+
|
56
|
+
if ((value = block.apply(#{self}, args)) === __breaker) {
|
48
57
|
return __breaker.$v;
|
49
58
|
}
|
50
59
|
|
@@ -58,16 +67,17 @@ module Enumerable
|
|
58
67
|
}
|
59
68
|
else {
|
60
69
|
proc = function(obj) {
|
61
|
-
if (obj !== false && obj !== nil) {
|
70
|
+
if ((obj !== false && obj !== nil) || arguments.length >= 2) {
|
62
71
|
result = true;
|
63
72
|
__breaker.$v = nil;
|
64
|
-
|
73
|
+
|
65
74
|
return __breaker;
|
66
75
|
}
|
67
76
|
}
|
68
77
|
}
|
69
78
|
|
70
|
-
#{self}.$each
|
79
|
+
#{self}.$each._p = proc;
|
80
|
+
#{self}.$each();
|
71
81
|
|
72
82
|
return result;
|
73
83
|
}
|
@@ -87,7 +97,8 @@ module Enumerable
|
|
87
97
|
result.push(value);
|
88
98
|
};
|
89
99
|
|
90
|
-
#{self}.$each
|
100
|
+
#{self}.$each._p = proc;
|
101
|
+
#{self}.$each();
|
91
102
|
|
92
103
|
return result;
|
93
104
|
}
|
@@ -110,7 +121,8 @@ module Enumerable
|
|
110
121
|
result = value;
|
111
122
|
};
|
112
123
|
|
113
|
-
#{self}.$each
|
124
|
+
#{self}.$each._p = proc;
|
125
|
+
#{self}.$each();
|
114
126
|
|
115
127
|
return result;
|
116
128
|
}
|
@@ -139,7 +151,8 @@ module Enumerable
|
|
139
151
|
}
|
140
152
|
}
|
141
153
|
|
142
|
-
#{self}.$each
|
154
|
+
#{self}.$each._p = proc;
|
155
|
+
#{self}.$each();
|
143
156
|
|
144
157
|
return result;
|
145
158
|
}
|
@@ -149,7 +162,7 @@ module Enumerable
|
|
149
162
|
%x{
|
150
163
|
var result = nil;
|
151
164
|
|
152
|
-
#{self}.$each
|
165
|
+
#{self}.$each._p = function(obj) {
|
153
166
|
var value;
|
154
167
|
|
155
168
|
if ((value = block(obj)) === __breaker) {
|
@@ -162,7 +175,9 @@ module Enumerable
|
|
162
175
|
|
163
176
|
return __breaker;
|
164
177
|
}
|
165
|
-
}
|
178
|
+
};
|
179
|
+
|
180
|
+
#{self}.$each();
|
166
181
|
|
167
182
|
if (result !== nil) {
|
168
183
|
return result;
|
@@ -181,13 +196,15 @@ module Enumerable
|
|
181
196
|
var result = [],
|
182
197
|
current = 0;
|
183
198
|
|
184
|
-
#{self}.$each
|
199
|
+
#{self}.$each._p = function(obj) {
|
185
200
|
if (number < current) {
|
186
201
|
result.push(e);
|
187
202
|
}
|
188
203
|
|
189
204
|
current++;
|
190
|
-
}
|
205
|
+
};
|
206
|
+
|
207
|
+
#{self}.$each()
|
191
208
|
|
192
209
|
return result;
|
193
210
|
}
|
@@ -197,7 +214,7 @@ module Enumerable
|
|
197
214
|
%x{
|
198
215
|
var result = [];
|
199
216
|
|
200
|
-
#{self}.$each
|
217
|
+
#{self}.$each._p = function(obj) {
|
201
218
|
var value;
|
202
219
|
|
203
220
|
if ((value = block(obj)) === __breaker) {
|
@@ -210,7 +227,9 @@ module Enumerable
|
|
210
227
|
}
|
211
228
|
|
212
229
|
return __breaker;
|
213
|
-
}
|
230
|
+
};
|
231
|
+
|
232
|
+
#{self}.$each();
|
214
233
|
|
215
234
|
return result;
|
216
235
|
}
|
@@ -220,14 +239,16 @@ module Enumerable
|
|
220
239
|
%x{
|
221
240
|
var all = [];
|
222
241
|
|
223
|
-
#{self}.$each
|
242
|
+
#{self}.$each._p = function(obj) {
|
224
243
|
all.push(obj);
|
225
244
|
|
226
245
|
if (all.length == n) {
|
227
246
|
block(all.slice(0));
|
228
247
|
all = [];
|
229
248
|
}
|
230
|
-
}
|
249
|
+
};
|
250
|
+
|
251
|
+
#{self}.$each();
|
231
252
|
|
232
253
|
// our "last" group, if smaller than n then wont have been yielded
|
233
254
|
if (all.length > 0) {
|
@@ -242,7 +263,7 @@ module Enumerable
|
|
242
263
|
%x{
|
243
264
|
var index = 0;
|
244
265
|
|
245
|
-
#{self}.$each
|
266
|
+
#{self}.$each._p = function(obj) {
|
246
267
|
var value;
|
247
268
|
|
248
269
|
if ((value = block(obj, index)) === __breaker) {
|
@@ -250,7 +271,8 @@ module Enumerable
|
|
250
271
|
}
|
251
272
|
|
252
273
|
index++;
|
253
|
-
}
|
274
|
+
};
|
275
|
+
#{self}.$each();
|
254
276
|
|
255
277
|
return nil;
|
256
278
|
}
|
@@ -258,13 +280,15 @@ module Enumerable
|
|
258
280
|
|
259
281
|
def each_with_object(object, &block)
|
260
282
|
%x{
|
261
|
-
#{self}.$each
|
283
|
+
#{self}.$each._p = function(obj) {
|
262
284
|
var value;
|
263
285
|
|
264
286
|
if ((value = block(obj, object)) === __breaker) {
|
265
287
|
return __breaker.$v;
|
266
288
|
}
|
267
|
-
}
|
289
|
+
};
|
290
|
+
|
291
|
+
#{self}.$each();
|
268
292
|
|
269
293
|
return object;
|
270
294
|
}
|
@@ -274,9 +298,11 @@ module Enumerable
|
|
274
298
|
%x{
|
275
299
|
var result = [];
|
276
300
|
|
277
|
-
#{self}.$each
|
301
|
+
#{self}.$each._p = function(obj) {
|
278
302
|
result.push(obj);
|
279
|
-
}
|
303
|
+
};
|
304
|
+
|
305
|
+
#{self}.$each();
|
280
306
|
|
281
307
|
return result;
|
282
308
|
}
|
@@ -288,7 +314,7 @@ module Enumerable
|
|
288
314
|
%x{
|
289
315
|
var result = [];
|
290
316
|
|
291
|
-
#{self}.$each
|
317
|
+
#{self}.$each._p = function(obj) {
|
292
318
|
var value;
|
293
319
|
|
294
320
|
if ((value = block(obj)) === __breaker) {
|
@@ -298,7 +324,9 @@ module Enumerable
|
|
298
324
|
if (value !== false && value !== nil) {
|
299
325
|
result.push(obj);
|
300
326
|
}
|
301
|
-
}
|
327
|
+
};
|
328
|
+
|
329
|
+
#{self}.$each();
|
302
330
|
|
303
331
|
return result;
|
304
332
|
}
|
@@ -335,7 +363,8 @@ module Enumerable
|
|
335
363
|
};
|
336
364
|
}
|
337
365
|
|
338
|
-
#{self}.$each
|
366
|
+
#{self}.$each._p = proc;
|
367
|
+
#{self}.$each();
|
339
368
|
|
340
369
|
return result;
|
341
370
|
}
|
@@ -364,7 +393,8 @@ module Enumerable
|
|
364
393
|
};
|
365
394
|
}
|
366
395
|
|
367
|
-
#{self}.$each
|
396
|
+
#{self}.$each._p = proc;
|
397
|
+
#{self}.$each();
|
368
398
|
|
369
399
|
return result;
|
370
400
|
}
|
@@ -374,7 +404,7 @@ module Enumerable
|
|
374
404
|
%x{
|
375
405
|
var result = [];
|
376
406
|
|
377
|
-
#{self}.$each(block !== nil
|
407
|
+
#{self}.$each._p = (block !== nil
|
378
408
|
? function(obj) {
|
379
409
|
var value = #{pattern === `obj`};
|
380
410
|
|
@@ -394,6 +424,8 @@ module Enumerable
|
|
394
424
|
}
|
395
425
|
});
|
396
426
|
|
427
|
+
#{self}.$each();
|
428
|
+
|
397
429
|
return result;
|
398
430
|
}
|
399
431
|
end
|
@@ -418,3 +450,4 @@ module Enumerable
|
|
418
450
|
|
419
451
|
alias inject reduce
|
420
452
|
end
|
453
|
+
|
data/opal/opal/error.rb
CHANGED