Socket
Socket
Sign inDemoInstall

strings

Package Overview
Dependencies
12
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.1 to 0.4.2

2

bower.json
{
"name": "strings",
"version": "0.4.0",
"version": "0.4.2",
"main": [

@@ -5,0 +5,0 @@ "index.js"

@@ -77,5 +77,2 @@ /**

var isPropstring = function(str) {
return /:/.test(str) ? 'null' : str;
};

@@ -85,2 +82,6 @@ Strings.prototype.propstring = function (name, str, options) {

function isPropstring(str) {
return /:/.test(str) ? '__null__' : str;
}
if (!str) {

@@ -126,3 +127,5 @@ // if `nonull:false` return the propstring or `'__null__'`

if (!pattern) {return this._patterns[name];}
if (!(pattern instanceof RegExp)) {
if (typeof pattern === 'object' && !(pattern instanceof RegExp)) {
pattern = pattern.re;
} else if (!(pattern instanceof RegExp)) {
pattern = new RegExp(pattern, flags || '');

@@ -136,2 +139,28 @@ }

/**
* ## .source
*
* Return the RegExp source from a stored `pattern`.
*
* ```js
* strings.source(name);
* ```
*
* **Example**
*
* ```js
* strings.pattern('foo', {re: /:([\\w]+)/gm});
* strings.source('foo');
* //=> ':([\\w]+)'
* ```
*
* @param {String} `name` The name of the stored pattern.
* @api public
*/
Strings.prototype.source = function (name) {
return this._patterns[name].source;
};
/**
* ## .replacement

@@ -161,3 +190,5 @@ *

Strings.prototype.replacement = function (name, replacement) {
if (!replacement) {return this._replacements[name];}
if (!replacement) {
return this._replacements[name];
}
this._replacements[name] = replacement;

@@ -190,3 +221,5 @@ return this;

Strings.prototype.parser = function (name, arr) {
if (!arr) {return this._parsers[name];}
if (!arr) {
return this._parsers[name];
}
this._parsers[name] = utils.arrayify(arr);

@@ -325,4 +358,9 @@ return this;

}
propstring = this.propstring(propstring);
this._templates[name] = {propstring: propstring, parsers: parsers};
this._templates[name] = {
propstring: propstring,
parsers: parsers
};
return this;

@@ -329,0 +367,0 @@ };

{
"name": "strings",
"version": "0.4.1",
"version": "0.4.2",
"description": "Easily replace and transform :props in strings.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/assemble/strings",

@@ -36,3 +36,3 @@ # strings [![NPM version](https://badge.fury.io/js/strings.png)](http://badge.fury.io/js/strings)

* `return` {Object} Instance of a Strings object
* `return` {Object} Instance of a Strings object

@@ -57,3 +57,2 @@

* `return` {Strings} to allow chaining
* `api` public

@@ -79,5 +78,23 @@

* `return` {Strings} to allow chaining
* `api` public
### .source
Return the RegExp source from a stored `pattern`.
```js
strings.source(name);
```
**Example**
```js
strings.pattern('foo', {re: /:([\\w]+)/gm});
strings.source('foo');
//=> ':([\\w]+)'
```
* `name` {String}: The name of the stored pattern.
### .replacement

@@ -103,3 +120,2 @@

* `return` {Strings} to allow chaining
* `api` public

@@ -145,3 +161,2 @@

* `return` {Strings} to allow chaining
* `api` public

@@ -199,3 +214,2 @@

* `return` {Array}
* `api` public

@@ -228,3 +242,2 @@

* `return` {Strings} to allow chaining
* `api` public

@@ -257,3 +270,2 @@

* `return` {Strings} to allow chaining
* `api` public

@@ -283,3 +295,2 @@

* `return` {Strings} to allow chaining
* `api` public

@@ -314,3 +325,2 @@

* `return` {String}
* `api` public

@@ -338,4 +348,3 @@

* `context` {Object}: Optional context object, to bind to replacement function as `this`
* `return` {String}
* `api` public
* `return` {String}

@@ -362,2 +371,2 @@

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 30, 2014._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 03, 2014._
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