Skip to content

Commit

Permalink
undocument addslashes param of vinterpolate, comments, readme edits
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasq committed Jun 28, 2019
1 parent f562d20 commit 0d289dd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Equivalent to `String.prototype.repeat`.
Backslash-escape all characters in str that would act as metacharacters inside a regular
expression. Returns the string with escapes added.

### qibl.vinterpolate( string, substring, argv [,addslashes] )
### qibl.vinterpolate( string, substring, argv )

Replace each occurrence of the substring in string with the next argument in the vector
argv. Substrings without a corresponding argument are not replaced.
Expand Down Expand Up @@ -111,13 +111,13 @@ newer node the constructor polyfill is slow compared to the `allocBuf` and `from
### qibl.allocBuf( length )

Create a new Buffer having the given length, with contents uninitialized. This builder is a
pass-through to the native implementation (`Buffer.allocUnsafe` or `Buffer`) and always runs
pass-through to the native implementation (`Buffer.allocUnsafe` or `new Buffer`) and always runs
at full speed.

### qibl.fromBuf( contents )

Create a new Buffer with its contents pre-initialized to the given string, array or buffer.
This builder is a pass-through to the native implementation (`Buffer.from` or `Buffer`) and
This builder is a pass-through to the native implementation (`Buffer.from` or `new Buffer`) and
always runs at full speed.


Expand Down Expand Up @@ -161,5 +161,6 @@ load.
Changelog
---------

- 1.1.1 - un-document the `addslashes` hidden param of `vinterpolate`
- 1.1.0 - new `tryRequire`
- 1.0.0 - first release
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qibl",
"version": "1.1.0",
"version": "1.1.1",
"description": "small functions I've found useful",
"keywords": [ "repeat", "fill", "assign", "merge", "polyfill", "toStruct" ],
"main": "qibl.js",
Expand Down
3 changes: 2 additions & 1 deletion qibl.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function isHash( obj ) {
return obj ? obj.constructor === Object : false;
}

// transfer the own properties of src onto target
// transfer the own properties of src onto target, aka Object.assign
// See also `qhash`.
function copyObject( target /* ,VARARGS */ ) {
for (var src, i = 1; i < arguments.length; i++) {
Expand Down Expand Up @@ -217,6 +217,7 @@ function values( object ) {
}

// replace each occurrence of patt in str with the next one of the args
// If an `addslashes` function is provided, use it to escape the args.
function vinterpolate( str, patt, args, addslashes ) {
var prevPos = 0, pos, ret = "", argix = 0;
while ((pos = str.indexOf(patt, prevPos)) >= 0 && argix < args.length) {
Expand Down
1 change: 1 addition & 0 deletions test-qibl.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ module.exports = {
t.equal(qibl.vinterpolate("foobar", "o", []), "foobar");
t.equal(qibl.vinterpolate("oooo", "o", ['O', 'OO']), "OOOoo");

// should use the provided `addslashes` function to escape the args
t.equal(qibl.vinterpolate("o", "o", ['$ok ;|\' 3'], qibl.addslashes), "$ok ;|\\\' 3");

t.done();
Expand Down

0 comments on commit 0d289dd

Please sign in to comment.