You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

prototypes

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prototypes - npm Package Compare versions

Comparing version

to
0.2.3

38

lib/string.js

@@ -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",