complete redesign: use nodejs on server instead of php - documentation to be updated
This commit is contained in:
23
nodejs/node_modules/stylus/lib/functions/replace.js
generated
vendored
Normal file
23
nodejs/node_modules/stylus/lib/functions/replace.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
var utils = require('../utils')
|
||||
, nodes = require('../nodes');
|
||||
|
||||
/**
|
||||
* Returns string with all matches of `pattern` replaced by `replacement` in given `val`
|
||||
*
|
||||
* @param {String} pattern
|
||||
* @param {String} replacement
|
||||
* @param {String|Ident} val
|
||||
* @return {String|Ident}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function replace(pattern, replacement, val){
|
||||
utils.assertString(pattern, 'pattern');
|
||||
utils.assertString(replacement, 'replacement');
|
||||
utils.assertString(val, 'val');
|
||||
pattern = new RegExp(pattern.string, 'g');
|
||||
var res = val.string.replace(pattern, replacement.string);
|
||||
return val instanceof nodes.Ident
|
||||
? new nodes.Ident(res)
|
||||
: new nodes.String(res);
|
||||
};
|
Reference in New Issue
Block a user