strings.js
Advanced tools
Comparing version 1.2.7 to 1.2.8
{ | ||
"name": "strings.js", | ||
"version": "1.2.7", | ||
"description": "A flexible Javascript string manipulation library.", | ||
"version": "1.2.8", | ||
"description": "A friendly Javascript string manipulation library.", | ||
"main": "strings.min.js", | ||
@@ -25,5 +25,3 @@ "scripts": { | ||
}, | ||
"homepage": "https://github.com/phazelift/strings.js", | ||
"dependencies": {}, | ||
"devDependencies": {} | ||
"homepage": "https://github.com/phazelift/strings.js" | ||
} |
strings.js | ||
========== | ||
A flexible, Javascript string manipulation library. Contains the usual suspects and some handy additions. | ||
A friendly Javascript string manipulation library. No cryptic names, no methods returning undefined when you expect | ||
a string, etc.. Contains the usual suspects and some handy additions. | ||
@@ -9,3 +10,3 @@ **key features:** | ||
- most methods are chainable for the dynamic part | ||
- Strings is 1 based; [1] is the first character of the string, [-1] the last | ||
- Strings is 1 based; 1 is the first character of the string, -1 the last | ||
- can use negative numbers in almost all methods to target from the end of the string | ||
@@ -18,3 +19,3 @@ - can target with indexes and substring arguments mixed in some methods | ||
______________________________________________ | ||
Some quick examples: | ||
### a quick example: | ||
```javascript | ||
@@ -49,8 +50,11 @@ // discover strings: | ||
___ | ||
**node.js** | ||
Made for browser and/or node.js. You can use `npm install strings.js` if you like. | ||
### node.js | ||
**AMD** | ||
When using AMD, you can load strings.js like so: | ||
Made for browser and/or node.js. You can use `npm install strings.js` at the base directory of your project, after that: | ||
```javascript | ||
var Strings= require( 'strings.js' ); | ||
``` | ||
### AMD | ||
```javascript | ||
require.config({ | ||
@@ -63,4 +67,4 @@ paths: { | ||
require( ['strings'], function( Strings ){ | ||
console.log( Strings.empty('') ); | ||
// true | ||
console.log( Strings.times(':)', 3) ); | ||
// :):):) | ||
}); | ||
@@ -70,4 +74,3 @@ ``` | ||
___ | ||
General description: | ||
-------------------- | ||
### general description: | ||
@@ -88,4 +91,4 @@ Because strings.js is build upon types.js it is very robust. Almost any String type argument accepts a Number type and viceversa. | ||
Included: | ||
--------- | ||
### included: | ||
types.js essential type-checker/enforcer is included in strings.js. It is the fundament for strings.js and can be found after | ||
@@ -99,4 +102,3 @@ loading strings.js like so: | ||
Some examples: | ||
------------ | ||
### some more examples: | ||
```javascript | ||
@@ -113,10 +115,13 @@ | ||
s.remove('Hello', 'library', ' '); // Strings! | ||
s.prepend('reversed ').reverse(); // !sgnirtS desrever | ||
s.prepend('reversed ').reverse(); // !sgnirtS desrever | ||
s.shuffle(); // getriever!nrss dS (random on every run) | ||
s.set(); // (.set with no usable argument wipes the string) | ||
s.set('Strings!').setWrap('<3 ').wrap; // <3 Strings! (.wrap only returns the wrapped string) | ||
s.applyWrap('I ', '!').get(88, 3, 4, 99); // <3 (88 and 99 are out of range and thus ignored) | ||
s.get(); // I <3 Strings! (wrap was applied to this.string) | ||
// wrap 'Strings' .wrap returns the wrapped string | ||
s.set('Strings').setWrap('<3 ', '!').wrap; // <3 Strings! | ||
// apply the wrap to s while wrapping it once again | ||
s.applyWrap('I ', '!!') | ||
s.get(); // I <3 Strings!!! | ||
// some static Methods | ||
@@ -150,4 +155,2 @@ // all comments reflect the value of s | ||
this.string represents the actual state of the internal dynamic string. | ||
This API is in development.. | ||
____ | ||
@@ -186,3 +189,3 @@ **Strings** constructor | ||
> Returns this.string's characters sorted by it's ordinal value. | ||
> Returns this.string's characters sorted by their ordinal value. | ||
```javascript | ||
@@ -198,3 +201,2 @@ var string= new Strings( 'sort', 'charcters', 'and', 5, 2, 9, 1 ); | ||
> Applies a random string with amount characters within asciiRange. asciiRange is an Array with two indices; [min, max]. | ||
> If you want a custom range, you can better use: new Strings('mysecret007shuffle').shuffle() | ||
```javascript | ||
@@ -216,5 +218,3 @@ // 10 random special characters | ||
string.xs( function(ch){ | ||
return (ch === ' ') | ||
? ' * ' | ||
: true; | ||
return (ch === ' ') ? ' * ' : true; | ||
}); | ||
@@ -616,11 +616,23 @@ console.log( string.$ ); | ||
var string= new Strings('<3').setWrap( 'she ', ' me'); | ||
// string is unchanged | ||
console.log( string.$ ); | ||
// <3 | ||
// but .wrap shows the string wrapped | ||
console.log( string.wrap+ '!' ); | ||
// she <3 me! | ||
// and why not wrap once more: | ||
string.setWrap('Will ', ' forever?'); | ||
console.log( string.wrap ); | ||
// she <3 me | ||
string.setWrap('would ', ' forever?'); | ||
console.log( string.wrap ); | ||
// would she <3 me forever? | ||
// Will she <3 me forever? | ||
// still not applied to string | ||
console.log( string.$+ '..' ); | ||
// <3.. | ||
// use .setWrap to apply the wrap to string | ||
string.applyWrap(); | ||
console.log( string.$ ); | ||
// Will she <3 me forever? | ||
``` | ||
@@ -891,3 +903,3 @@ | ||
> The full library (1.8kb) is included in strings.js. Check https://github.com/phazelift/types.js for general info and API. | ||
> The full library (~2kB) is included in strings.js. Check https://github.com/phazelift/types.js for general info and API. | ||
@@ -894,0 +906,0 @@ |
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
213449
970