prototypes
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -217,5 +217,2 @@ 'use strict'; | ||
/** | ||
* Test repeat. | ||
*/ | ||
function testRepeat(callback) | ||
@@ -238,2 +235,20 @@ { | ||
/** | ||
* Pad a string with the given character. | ||
*/ | ||
newString.pad = function(length, character) | ||
{ | ||
character = character || ' '; | ||
return character.repeat(length - this.length) + this; | ||
}; | ||
function testPad(callback) | ||
{ | ||
testing.assertEquals('1'.pad(2, '0'), '01', 'Invalid numeric padding', callback); | ||
testing.assertEquals(' a'.pad(3, 'p'), 'p a', 'Invalid string padding', callback); | ||
testing.assertEquals('a'.pad(3), ' a', 'Invalid default padding', callback); | ||
testing.assertEquals('aaaa'.pad(2), 'aaaa', 'Truncated padding', callback); | ||
testing.success(callback); | ||
} | ||
// add new string functions to string prototype | ||
@@ -247,10 +262,11 @@ core.addProperties(String.prototype, newString); | ||
{ | ||
var tests = { | ||
testGlobalRegExp: testGlobalRegExp, | ||
startsEndsWith: testStartsEndsWith, | ||
substrings: testSubstrings, | ||
contains: testContains, | ||
replaceAll: testReplaceAll, | ||
repeat: testRepeat, | ||
}; | ||
var tests = [ | ||
testGlobalRegExp, | ||
testStartsEndsWith, | ||
testSubstrings, | ||
testContains, | ||
testReplaceAll, | ||
testRepeat, | ||
testPad, | ||
]; | ||
testing.run(tests, callback); | ||
@@ -257,0 +273,0 @@ }; |
{ | ||
"name": "prototypes", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26196
694