prototypes
Advanced tools
Comparing version 0.1.7 to 0.2.0
@@ -73,2 +73,4 @@ 'use strict'; | ||
testing.assert(exports.isNumber(8e5), '8e5 should be number', callback); | ||
testing.assert(exports.isNumber('1'), '"1" should be number', callback); | ||
testing.assert(exports.isNumber('-1'), '"-1" should be number', callback); | ||
testing.assert(!exports.isNumber(NaN), 'NaN should not be number', callback); | ||
@@ -75,0 +77,0 @@ testing.assert(!exports.isNumber('a'), 'a should not be number', callback); |
@@ -95,3 +95,3 @@ 'use strict'; | ||
var value = overwriter[key]; | ||
if (value) | ||
if (value !== undefined) | ||
{ | ||
@@ -118,4 +118,14 @@ this[key] = value; | ||
first.overwriteWith(second); | ||
testing.assertEquals(first.countProperties(), 3, 'Overwritten should have three properties', callback); | ||
testing.assertEquals(first.countProperties(), 3, 'Overwritten should have 3 properties', callback); | ||
testing.assertEquals(first.b, 'b2', 'Property in first should be replaced with second', callback); | ||
first.overwriteWith(undefined); | ||
testing.assertEquals(first.countProperties(), 3, 'Overwritten with undefined should have 3 properties', callback); | ||
var third = { | ||
u: null, | ||
v: undefined, | ||
w: 0, | ||
}; | ||
first.overwriteWith(third); | ||
testing.assertEquals(first.countProperties(), 5, 'Overwritten with third should have 5 properties', callback); | ||
testing.assert(first.w === 0, 'Overwritten with 0 should be there', callback); | ||
testing.success(callback); | ||
@@ -132,6 +142,6 @@ } | ||
{ | ||
var tests = { | ||
testCountProperties: testCountProperties, | ||
overwrite: testOverwriteObject, | ||
}; | ||
var tests = [ | ||
testCountProperties, | ||
testOverwriteObject, | ||
]; | ||
testing.run(tests, callback); | ||
@@ -138,0 +148,0 @@ }; |
{ | ||
"name": "prototypes", | ||
"version": "0.1.7", | ||
"version": "0.2.0", | ||
"description": "Some common prototypes for node.js: string.startsWith(), object.countProperties() and more. Functions are added using Object.defineProperty() to avoid polluting new objects.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/alexfernandez/prototypes", |
@@ -55,3 +55,3 @@ [![Build Status](https://secure.travis-ci.org/alexfernandez/prototypes.png)](http://travis-ci.org/alexfernandez/prototypes) | ||
'pepitus'.startsWith('tus'); | ||
'pepitus'.endsWith('tus'); | ||
\=> true | ||
@@ -61,3 +61,5 @@ | ||
Return the piece of string until the argument is found. Example: | ||
Return the piece of string until the argument is found; | ||
return the whole string if not found. | ||
Example: | ||
@@ -69,3 +71,5 @@ 'hi.there'.substringUpTo('.'); | ||
Return the piece of string until the last occurrence of the argument. Example: | ||
Return the piece of string until the last occurrence of the argument; | ||
return the whole string if not found. | ||
Example: | ||
@@ -72,0 +76,0 @@ 'hi.there.you'.substringUpToLast('.'); |
24197
626
239