Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "rubyisms", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Ruby style ES5 prototype extensions.", | ||
@@ -16,3 +16,3 @@ "keywords": [ | ||
"type": "git", | ||
"url": "https://github.com/Oka-/rubyisms" | ||
"url": "https://github.com/Okahyphen/rubyisms" | ||
}, | ||
@@ -19,0 +19,0 @@ "scripts": { |
@@ -23,11 +23,12 @@ // Colin 'Oka' Hall-Coates | ||
symbolWithCombiningMarks: /([\0-\u02FF\u0370-\u1AAF\u1B00-\u1DBF\u1E00-\u20CF\u2100-\uD7FF\uE000-\uFE1F\uFE30-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])([\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]+)/g, | ||
surrogatePair: /([\uD800-\uDBFF])([\uDC00-\uDFFF])/g | ||
surrogatePair: /([\uD800-\uDBFF])([\uDC00-\uDFFF])/g, | ||
crlf: /\r\n/ | ||
}; | ||
/* jshint -W040 */ | ||
function define (s, v) { | ||
function define (property, value) { | ||
var isObject = (toString.call(this) === types.obj); | ||
Object.defineProperty(this, s, { | ||
value: v, | ||
Object.defineProperty(this, property, { | ||
value: value, | ||
writable: true, | ||
@@ -40,28 +41,28 @@ enumerable: isObject, | ||
function strap (g, s) { | ||
return { get: g, set: function (v) { | ||
define.call(this, s, v); | ||
function strap (property, method) { | ||
return { get: method, set: function (value) { | ||
define.call(this, property, value); | ||
}, configurable: true }; | ||
} | ||
function minor (prototype, o, callback) { | ||
for (var k in o) { | ||
if (o.hasOwnProperty(k) && !prototype.hasOwnProperty(k)) { | ||
Object.defineProperty(prototype, k, strap(o[k], k)); | ||
if (callback) callback.call(null, k); | ||
function minor (prototype, object, callback) { | ||
Object.keys(object).forEach(function (key) { | ||
if (!prototype.hasOwnProperty(key)) { | ||
Object.defineProperty(prototype, key, strap(key, object[key])); | ||
if (callback) callback(key); | ||
} | ||
} | ||
}); | ||
} | ||
function major (prototype, o, callback) { | ||
for (var k in o) { | ||
if (o.hasOwnProperty(k) && !prototype.hasOwnProperty(k)) { | ||
Object.defineProperty(prototype, k, { | ||
value: o[k], | ||
function major (prototype, object, callback) { | ||
Object.keys(object).forEach(function (key) { | ||
if (!prototype.hasOwnProperty(key)) { | ||
Object.defineProperty(prototype, key, { | ||
value: object[key], | ||
writable: true, | ||
configurable: true | ||
}); | ||
if (callback) callback.call(null, k); | ||
if (callback) callback(key); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -286,2 +287,3 @@ | ||
if ( | ||
regex.crlf.test(end) || | ||
regex.surrogatePair.test(end) || | ||
@@ -524,3 +526,3 @@ regex.symbolWithCombiningMarks.test(end) | ||
return (typeof after === 'function'? after.call(this) : after); | ||
return (typeof after === 'function' ? after.call(this) : after); | ||
}, | ||
@@ -536,3 +538,3 @@ times: function (callback, after) { | ||
return (typeof after === 'function'? after.call(this) : after); | ||
return (typeof after === 'function' ? after.call(this) : after); | ||
}, | ||
@@ -551,3 +553,3 @@ upto: function (end, callback, after) { | ||
return (typeof after === 'function'? after.call(this) : after); | ||
return (typeof after === 'function' ? after.call(this) : after); | ||
} | ||
@@ -574,6 +576,6 @@ }); | ||
return (typeof after === 'function'? after.call(this) : after); | ||
return (typeof after === 'function' ? after.call(this) : after); | ||
}, | ||
eql: function (o) { | ||
return this === o; | ||
eql: function (object) { | ||
return this === object; | ||
}, | ||
@@ -608,6 +610,6 @@ fetch: function (key, substitute) { | ||
return (typeof after === 'function'? after.call(this) : after); | ||
return (typeof after === 'function' ? after.call(this) : after); | ||
}, | ||
prepend: function (o) { | ||
return o + this; | ||
prepend: function (object) { | ||
return object + this; | ||
} | ||
@@ -614,0 +616,0 @@ }); |
@@ -23,3 +23,3 @@ var chai = require('chai'), | ||
foo.should.equal('hello'); | ||
}) | ||
}); | ||
}); | ||
@@ -53,5 +53,11 @@ | ||
it('should remove \\r\\n from the end of a string', function () { | ||
var qar = 'hello\r\n'; | ||
expect(qar.chop).to.equal('hello'); | ||
}); | ||
it('should not affect the original', function () { | ||
foo.should.equal('hello'); | ||
}); | ||
}); | ||
}); | ||
@@ -98,3 +104,3 @@ | ||
baz.should.be.true; | ||
}) | ||
}); | ||
@@ -121,3 +127,3 @@ it('should not affect the original', function () { | ||
foo.should.equal('hello'); | ||
}); | ||
}); | ||
}); | ||
@@ -127,3 +133,3 @@ | ||
var foo = 'HeLlO', | ||
bar = foo.swapcase | ||
bar = foo.swapcase; | ||
@@ -168,3 +174,3 @@ it('should return a string with each character swapped in case', function () { | ||
foo.should.equal('hello'); | ||
}) | ||
}); | ||
}); | ||
@@ -184,2 +190,2 @@ | ||
}); | ||
}); | ||
}); |
58970
1389