Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6639f14a8ad8
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7718535c433f
Choose a head ref
  • 3 commits
  • 26 files changed
  • 1 contributor

Commits on Nov 8, 2013

  1. Copy the full SHA
    07b974d View commit details
  2. Spaces cleanup in Boolean

    meh committed Nov 8, 2013
    Copy the full SHA
    87f498c View commit details
  3. Copy the full SHA
    7718535 View commit details
19 changes: 0 additions & 19 deletions opal/core/array.rb
Original file line number Diff line number Diff line change
@@ -1227,25 +1227,6 @@ def to_a

alias to_ary to_a

def to_n
%x{
var result = [], obj
for (var i = 0, len = self.length; i < len; i++) {
obj = self[i];
if (#{`obj`.respond_to? :to_n}) {
result.push(#{`obj`.to_n});
}
else {
result.push(obj);
}
}
return result;
}
end

alias to_s inspect

def transpose
8 changes: 2 additions & 6 deletions opal/core/boolean.rb
Original file line number Diff line number Diff line change
@@ -28,14 +28,10 @@ def ==(other)
def to_s
`(self == true) ? 'true' : 'false'`
end

def to_n
`self.valueOf()`
end
end

TrueClass = Boolean
TrueClass = Boolean
FalseClass = Boolean

TRUE = true
TRUE = true
FALSE = false
50 changes: 10 additions & 40 deletions opal/core/hash.rb
Original file line number Diff line number Diff line change
@@ -28,8 +28,9 @@ class Hash
}
}
else {
for (var i = 0, length = arguments.length, key; i < length; i++) {
var key = arguments[i], obj = arguments[++i];
for (var i = 0, length = arguments.length; i < length; i++) {
var key = arguments[i],
obj = arguments[++i];
if (assocs[key] == null) {
keys.push(key);
@@ -50,8 +51,10 @@ class Hash
%x{
var $hash2 = Opal.hash2 = function(keys, map) {
var hash = new Hash._alloc;
hash.keys = keys;
hash.map = map;
hash.map = map;
return hash;
};
}
@@ -65,27 +68,18 @@ def self.[](*objs)
def self.allocate
%x{
var hash = new self._alloc;
hash.map = {};
hash.map = {};
hash.keys = [];
return hash;
}
end

def initialize(defaults = undefined, &block)
%x{
if (defaults != null) {
if (defaults.constructor == Object) {
var map = self.map, keys = self.keys, value;
for (var key in defaults) {
keys.push(key);
value = defaults[key];
map[key] = value != null ? value : nil
}
}
else {
self.none = defaults;
}
self.none = defaults;
}
else if (block !== nil) {
self.proc = block;
@@ -725,30 +719,6 @@ def to_hash
self
end

def to_n
%x{
var result = {},
keys = self.keys,
map = self.map,
bucket,
value;
for (var i = 0, length = keys.length; i < length; i++) {
var key = keys[i],
obj = map[key];
if (#{`obj`.respond_to? :to_n}) {
result[key] = #{`obj`.to_n};
}
else {
result[key] = obj;
}
}
return result;
}
end

alias to_s inspect

alias update merge!
5 changes: 1 addition & 4 deletions opal/core/kernel.rb
Original file line number Diff line number Diff line change
@@ -58,9 +58,6 @@ def Array(object, *args, &block)
if (object == null || object === nil) {
return [];
}
else if (#{native?(object)}) {
return #{Native::Array.new(object, *args, &block).to_a};
}
else if (#{object.respond_to? :to_ary}) {
return #{object.to_ary};
}
@@ -434,7 +431,7 @@ def raise(exception = undefined, string = undefined)
if (exception == null && #$!) {
exception = #$!;
}
else if (typeof(exception) === 'string') {
else if (exception._isString) {
exception = #{RuntimeError.new exception};
}
else if (!#{exception.is_a? Exception}) {
4 changes: 0 additions & 4 deletions opal/core/match_data.rb
Original file line number Diff line number Diff line change
@@ -85,10 +85,6 @@ def to_s
`#@matches[0]`
end

def to_n
@matches
end

def values_at(*indexes)
%x{
var values = [],
Loading