Socket
Socket
Sign inDemoInstall

mol-proto

Package Overview
Dependencies
0
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.14 to 0.1.15

27

lib/proto_string.js

@@ -18,2 +18,3 @@ 'use strict';

* - [unPrefix](#unPrefix)
* - [format](#format)
*/

@@ -30,3 +31,4 @@ var stringMethods = module.exports = {

hashCode: hashCode,
unPrefix: unPrefix
unPrefix: unPrefix,
format: format
};

@@ -188,1 +190,24 @@

}
/**
* Regex used to identify format vars
* @type {RegExp}
*/
var formatRegexp = /\$[0-9]+|\$\$/g;
/**
* String formatting utility to swap out tokens for variables.
* @param {String} this The string to be formatted
* @param {Array} args The values to be formatted
* @return {String} The formatted string
*/
function format() { // , ... arguments
var str = this;
var args = arguments;
return str.replace(formatRegexp, function(item) {
if (item == '$$') return '$';
item = item.slice(1);
return args[item - 1];
});
};

@@ -101,2 +101,3 @@ 'use strict';

* - [unPrefix](proto_string.js.html#unPrefix)
* - [format](proto_string.js.html#format)
*/

@@ -103,0 +104,0 @@ var stringMethods = require('./proto_string');

2

package.json
{
"name": "mol-proto",
"version": "0.1.14",
"version": "0.1.15",
"description": "ES5 object manipulation library for node and modern browsers",

@@ -5,0 +5,0 @@ "main": "lib/proto.js",

@@ -126,2 +126,3 @@ proto

* [unPrefix](http://milojs.github.io/proto/proto_string.js.html#unPrefix)
* [format](http://milojs.github.io/proto/proto_string.js.html#format)

@@ -128,0 +129,0 @@ * [__Number functions__](http://milojs.github.io/proto/proto_number.js.html)

@@ -103,2 +103,7 @@ 'use strict';

});
it('should define format function', function() {
assert.equal(_.format('foo$1and$2bar$1', 'x', 'y'), 'fooxandybarx')
assert.equal(_.format('this $1 is a $$ test', 'yo'), 'this yo is a $ test')
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc