string-kit
Advanced tools
Comparing version 0.0.2 to 0.0.3
# TOC | ||
- [format()](#format) | ||
- [Escape](#escape) | ||
<a name=""></a> | ||
@@ -7,2 +8,11 @@ | ||
# format() | ||
should perform basic examples. | ||
```js | ||
expect( format( 'Hello world' ) ).to.be( 'Hello world' ) ; | ||
expect( format( 'Hello %s' , 'world' ) ).to.be( 'Hello world' ) ; | ||
expect( format( 'Hello %s %s, how are you?' , 'Joe' , 'Doe' ) ).to.be( 'Hello Joe Doe, how are you?' ) ; | ||
expect( format( 'I have %i cookies.' , 3 ) ).to.be( 'I have 3 cookies.' ) ; | ||
``` | ||
%u should format unsigned integer. | ||
@@ -26,8 +36,8 @@ | ||
should. | ||
should perform well the argument's number feature. | ||
```js | ||
expect( format( 'ABC: %s%s%s' , 'A' , 'B' , 'C' ) ) ; | ||
expect( format( 'BAC: %+1s%-1s%s' , 'A' , 'B' , 'C' ) ) ; | ||
expect( format( 'CBC: %3s%s' , 'A' , 'B' , 'C' ) ) ; | ||
expect( format( '%s%s%s' , 'A' , 'B' , 'C' ) ).to.be( 'ABC' ) ; | ||
expect( format( '%+1s%-1s%s' , 'A' , 'B' , 'C' ) ).to.be( 'BAC' ) ; | ||
expect( format( '%3s%s' , 'A' , 'B' , 'C' ) ).to.be( 'CBC' ) ; | ||
``` | ||
@@ -56,1 +66,3 @@ | ||
<a name="escape"></a> | ||
# Escape |
@@ -222,11 +222,11 @@ /* | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions | ||
string.escape.regexp = function escapeRegexp( str ) | ||
{ | ||
string.escape.regExp = function escapeRegExp( str ) { | ||
return str.replace( /([.*+?^${}()|\[\]\/\\])/g , '\\$1' ) ; | ||
} ; | ||
string.escape.shellArg = function escapeShellArg( str ) { | ||
return '\'' + str.replace( /\'/g , "'\\''" ) + '\'' ; | ||
} ; | ||
module.exports = string ; | ||
{ | ||
"name": "string-kit", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A string manipulation toolbox.", | ||
@@ -5,0 +5,0 @@ "main": "lib/string.js", |
@@ -28,2 +28,3 @@ | ||
- [format()](#format) | ||
- [Escape](#escape) | ||
<a name=""></a> | ||
@@ -33,2 +34,11 @@ | ||
# format() | ||
should perform basic examples. | ||
```js | ||
expect( format( 'Hello world' ) ).to.be( 'Hello world' ) ; | ||
expect( format( 'Hello %s' , 'world' ) ).to.be( 'Hello world' ) ; | ||
expect( format( 'Hello %s %s, how are you?' , 'Joe' , 'Doe' ) ).to.be( 'Hello Joe Doe, how are you?' ) ; | ||
expect( format( 'I have %i cookies.' , 3 ) ).to.be( 'I have 3 cookies.' ) ; | ||
``` | ||
%u should format unsigned integer. | ||
@@ -52,8 +62,8 @@ | ||
should. | ||
should perform well the argument's number feature. | ||
```js | ||
expect( format( 'ABC: %s%s%s' , 'A' , 'B' , 'C' ) ) ; | ||
expect( format( 'BAC: %+1s%-1s%s' , 'A' , 'B' , 'C' ) ) ; | ||
expect( format( 'CBC: %3s%s' , 'A' , 'B' , 'C' ) ) ; | ||
expect( format( '%s%s%s' , 'A' , 'B' , 'C' ) ).to.be( 'ABC' ) ; | ||
expect( format( '%+1s%-1s%s' , 'A' , 'B' , 'C' ) ).to.be( 'BAC' ) ; | ||
expect( format( '%3s%s' , 'A' , 'B' , 'C' ) ).to.be( 'CBC' ) ; | ||
``` | ||
@@ -82,1 +92,3 @@ | ||
<a name="escape"></a> | ||
# Escape |
@@ -46,2 +46,10 @@ /* | ||
it( "should perform basic examples" , function() { | ||
expect( format( 'Hello world' ) ).to.be( 'Hello world' ) ; | ||
expect( format( 'Hello %s' , 'world' ) ).to.be( 'Hello world' ) ; | ||
expect( format( 'Hello %s %s, how are you?' , 'Joe' , 'Doe' ) ).to.be( 'Hello Joe Doe, how are you?' ) ; | ||
expect( format( 'I have %i cookies.' , 3 ) ).to.be( 'I have 3 cookies.' ) ; | ||
} ) ; | ||
it( "%u should format unsigned integer" , function() { | ||
@@ -63,7 +71,7 @@ | ||
it( "should" , function() { | ||
it( "should perform well the argument's number feature" , function() { | ||
expect( format( 'ABC: %s%s%s' , 'A' , 'B' , 'C' ) ) ; | ||
expect( format( 'BAC: %+1s%-1s%s' , 'A' , 'B' , 'C' ) ) ; | ||
expect( format( 'CBC: %3s%s' , 'A' , 'B' , 'C' ) ) ; | ||
expect( format( '%s%s%s' , 'A' , 'B' , 'C' ) ).to.be( 'ABC' ) ; | ||
expect( format( '%+1s%-1s%s' , 'A' , 'B' , 'C' ) ).to.be( 'BAC' ) ; | ||
expect( format( '%3s%s' , 'A' , 'B' , 'C' ) ).to.be( 'CBC' ) ; | ||
} ) ; | ||
@@ -92,1 +100,10 @@ | ||
describe( "Escape" , function() { | ||
it( "escape.regExp" ) ; | ||
it( "escape.shellArg" ) ; | ||
} ) ; | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20083
252
91