Gathering detailed insights and metrics for string
Gathering detailed insights and metrics for string
npm install string
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
44,109,950
Last Day
11,687
Last Week
48,923
Last Month
228,213
Last Year
3,466,314
1,811 Stars
321 Commits
235 Forks
53 Watching
3 Branches
31 Contributors
Latest Version
3.3.3
Package Id
string@3.3.3
Size
49.92 kB
NPM Version
3.10.3
Node Version
6.7.0
Publised On
11 Oct 2016
Cumulative downloads
Total Downloads
Last day
0.6%
11,687
Compared to previous day
Last week
-16.8%
48,923
Compared to previous week
Last month
-3.9%
228,213
Compared to previous month
Last year
-15.5%
3,466,314
Compared to previous year
string.js
, or simply S
is a lightweight (< 5 kb minified and gzipped) JavaScript library for the browser or for Node.js that provides extra String methods. Originally, it modified the String prototype. But I quickly learned that in JavaScript, this is considered poor practice.
Personally, I prefer the cleanliness of the way code looks when it appears to be native methods. i.e. when you modify native JavaScript prototypes. However, if any app dependency required string.js
, then the app's string prototype would be modified in every module. This could be troublesome. So I settled on creating a wrapper a la jQuery style. For those of you prototype hatin' fools, there is the method extendPrototype()
.
Here's a list of alternative frameworks:
Why wasn't I happy with any of them? They are all static methods that don't seem to support chaining in a clean way 'OR' they have an odd dependency. Sugar is the notable exception.
If you want to use this library, you first need to install the [Node.js] (https://nodejs.org/en/).
When you install node.js, will also be installed [npm] (https://www.npmjs.com/).
Please run the following command.
npm install --save string
Assuming you're on http://stringjs.com, just simply open up the Webkit inspector in either Chrome or Safari, or the web console in Firefox and you'll notice that string.js
is included in this page so that you can start experimenting with it right away.
1var S = require('string');
Originally, I was using $s
but glancing over the code, it was easy to confuse $s
for string.js with $
for jQuery. Feel free to use the most convenient variable for you.
Checkout this gem to easily use string.js on the asset pipeline: https://github.com/jesjos/stringjs-rails
1<!-- HTML5 --> 2<script src="https://cdn.rawgit.com/jprichardson/string.js/master/dist/string.min.js"></script> 3 4<!-- Note that in the mime type for Javascript is now officially 'application/javascript'. If you 5set the type to application/javascript in IE browsers, your Javacript will fail. Just don't set a 6type via the script tag and set the mime type from your server. Most browsers look at the server mime 7type anyway --> 8 9<!-- For HTML4/IE --> 10<script type="text/javascript" src="https://cdn.rawgit.com/jprichardson/string.js/master/dist/string.min.js"></script>
A global variable window.S
or simply S
is created.
It now has AMD support. See require.js on how to use with AMD modules.
1var doesIt = S('my cool string').left(2).endsWith('y'); //true
Access the wrapped string using s
variable or toString()
1var name = S('Your name is JP').right(2).s; //'JP'
is the same as…
1var name = S('Your name is JP').right(2).toString(); //'JP'
Still like the clean look of calling these methods directly on native Strings? No problem. Call extendPrototype()
. Make sure to not call this at the module level, at it'll effect the entire application lifecycle. You should really only use this at the method level. The one exception being if your application will not be a dependency of another application.
1S.extendPrototype(); 2var name = 'Your name is JP'.right(2); //'JP' 3S.restorePrototype(); //be a good citizen and clean up
string.js
has been designed to be compatible with Node.js and with IE6+, Firefox 3+, Safari 2+, Chrome 3+. Please click here to run the tests in your browser. Report any browser issues here: https://github.com/jprichardson/string.js/issues
See: https://github.com/jprichardson/string.js/pull/57
string.js
imports all of the native JavaScript methods. This is for convenience. The only difference is that the imported methods return string.js
objects instead of native JavaScript strings. The one exception to this is the method charAt(index)
. This is because charAt()
only returns a string of length one. This is typically done for comparisons and a string.js
object will have little to no value here.
All of the native methods support chaining with the string.js
methods.
Example:
1var S = require('string'); 2 3var phrase = S('JavaScript is the best scripting language ever!'); 4var sub = 'best scripting'; 5var pos = phrase.indexOf(sub); 6console.log(phrase.substr(pos, sub.length).truncate(8)); //best...
See test file for more details.
I use the same nomenclature as Objective-C regarding methods. + means static
or class
method. - means non-static
or instance
method.
This creates a new string.js
object. The parameter can be anything. The toString()
method will be called on any objects. Some native objects are used in some functions such as toCSV()
.
Example:
1S('hello').s //"hello" 2S(['a,b']).s //"a,b" 3S({hi: 'jp'}).s //"[object Object]""
Extracts a string between left
and right
strings.
Example:
1S('<a>foo</a>').between('<a>', '</a>').s // => 'foo' 2S('<a>foo</a></a>').between('<a>', '</a>').s // => 'foo' 3S('<a><a>foo</a></a>').between('<a>', '</a>').s // => '<a>foo' 4S('<a>foo').between('<a>', '</a>').s // => '' 5S('Some strings } are very {weird}, dont you think?').between('{', '}').s // => 'weird' 6S('This is a test string').between('test').s // => ' string' 7S('This is a test string').between('', 'test').s // => 'This is a '
Remove any underscores or dashes and convert a string into camel casing.
Example:
1S('data_rate').camelize().s; //'dataRate' 2S('background-color').camelize().s; //'backgroundColor' 3S('-moz-something').camelize().s; //'MozSomething' 4S('_car_speed_').camelize().s; //'CarSpeed' 5S('yes_we_can').camelize().s; //'yesWeCan'
Capitalizes the first character of a string.
Example:
1S('jon').capitalize().s; //'Jon' 2S('JP').capitalize().s; //'Jp'
Removes prefix
from start of string.
Example:
1S('foobar').chompLeft('foo').s; //'bar' 2S('foobar').chompLeft('bar').s; //'foobar'
Removes suffix
from end of string.
Example:
1S('foobar').chompRight('bar').s; //'foo' 2S('foobar').chompRight('foo').s; //'foobar'
Converts all adjacent whitespace characters to a single space.
Example:
1var str = S(' String \t libraries are \n\n\t fun\n! ').collapseWhitespace().s; //'String libraries are fun !'
Returns true if the string contains ss
.
Alias: include()
Example:
1S('JavaScript is one of the best languages!').contains('one'); //true
Returns the count of the number of occurrences of the substring.
Example:
1S('JP likes to program. JP does not play in the NBA.').count("JP")// 2 2S('Does not exist.').count("Flying Spaghetti Monster") //0 3S('Does not exist.').count("Bigfoot") //0 4S('JavaScript is fun, therefore Node.js is fun').count("fun") //2 5S('funfunfun').count("fun") //3
Returns a converted camel cased string into a string delimited by dashes.
Examples:
1S('dataRate').dasherize().s; //'data-rate' 2S('CarSpeed').dasherize().s; //'-car-speed' 3S('yesWeCan').dasherize().s; //'yes-we-can' 4S('backgroundColor').dasherize().s; //'background-color'
Decodes HTML entities into their string representation.
1S('Ken Thompson & Dennis Ritchie').decodeHTMLEntities().s; //'Ken Thompson & Dennis Ritchie' 2S('3 < 4').decodeHTMLEntities().s; //'3 < 4'
Returns true if the string ends with ss
.
Example:
1S("hello jon").endsWith('jon'); //true
Escapes the html.
Example:
1S('<div>hi</div>').escapeHTML().s; //<div>hi</div>
Modifies String.prototype
to have all of the methods found in string.js.
Example:
1S.extendPrototype();
Ensures string starts with prefix
.
Example:
1S('subdir').ensureLeft('/').s; //'/subdir' 2S('/subdir').ensureLeft('/').s; //'/subdir'
Ensures string ends with suffix
.
Example:
1S('dir').ensureRight('/').s; //'dir/' 2S('dir/').ensureRight('/').s; //'dir/'
Transforms the input into a human friendly form.
Example:
1S('the_humanize_string_method').humanize().s //'The humanize string method' 2S('ThehumanizeStringMethod').humanize().s //'Thehumanize string method' 3S('the humanize string method').humanize().s //'The humanize string method' 4S('the humanize_id string method_id').humanize().s //'The humanize id string method' 5S('the humanize string method ').humanize().s //'The humanize string method' 6S(' capitalize dash-CamelCase_underscore trim ').humanize().s //'Capitalize dash camel case underscore trim'
Returns true if the string contains the ss
.
Alias: contains()
Example:
1S('JavaScript is one of the best languages!').include('one'); //true
Return true if the string contains only letters.
Example:
1S("afaf").isAlpha(); //true 2S('fdafaf3').isAlpha(); //false 3S('dfdf--dfd').isAlpha(); //false
Return true if the string contains only letters and numbers
Example:
1S("afaf35353afaf").isAlphaNumeric(); //true 2S("FFFF99fff").isAlphaNumeric(); //true 3S("99").isAlphaNumeric(); //true 4S("afff").isAlphaNumeric(); //true 5S("Infinity").isAlphaNumeric(); //true 6S("-Infinity").isAlphaNumeric(); //false 7S("-33").isAlphaNumeric(); //false 8S("aaff..").isAlphaNumeric(); //false
Return true if the string is solely composed of whitespace or is null
/undefined
.
Example:
1S(' ').isEmpty(); //true 2S('\t\t\t ').isEmpty(); //true 3S('\n\n ').isEmpty(); //true 4S('helo').isEmpty(); //false 5S(null).isEmpty(); //true 6S(undefined).isEmpty(); //true
Return true if the character or string is lowercase
Example:
1S('a').isLower(); //true 2S('z').isLower(); //true 3S('B').isLower(); //false 4S('hijp').isLower(); //true 5S('hi jp').isLower(); //false 6S('HelLO').isLower(); //false
Return true if the string only contains digits
Example:
1S("3").isNumeric(); //true 2S("34.22").isNumeric(); //false 3S("-22.33").isNumeric(); //false 4S("NaN").isNumeric(); //false 5S("Infinity").isNumeric(); //false 6S("-Infinity").isNumeric(); //false 7S("JP").isNumeric(); //false 8S("-5").isNumeric(); //false 9S("000992424242").isNumeric(); //true
Returns true if the character or string is uppercase
Example:
1S('a').isUpper() //false 2S('z').isUpper() //false 3S('B').isUpper() //true 4S('HIJP').isUpper() //true 5S('HI JP').isUpper() //false 6S('HelLO').isUpper() //true
Removes accents from Latin characters.
1S('crème brûlée').latinise().s // 'creme brulee'
Return the substring denoted by n
positive left-most characters.
Example:
1S('My name is JP').left(2).s; //'My' 2S('Hi').left(0).s; //'' 3S('My name is JP').left(-2).s; //'JP', same as right(2)
Property to return the length of the string object.
Example:
1S('hi').length; //2
Returns an array with the lines. Cross-platform compatible.
Example:
1var stuff = "My name is JP\nJavaScript is my fav language\r\nWhat is your fav language?" 2var lines = S(stuff).lines() 3 4console.dir(lines) 5/* 6[ 'My name is JP', 7 'JavaScript is my fav language', 8 'What is your fav language?' ] 9*/
Pads the string in the center with specified character. char
may be a string or a number, defaults is a space.
Example:
1S('hello').pad(5).s //'hello' 2S('hello').pad(10).s //' hello ' 3S('hey').pad(7).s //' hey ' 4S('hey').pad(5).s //' hey ' 5S('hey').pad(4).s //' hey' 6S('hey').pad(7, '-').s//'--hey--'
Left pads the string.
Example:
1S('hello').padLeft(5).s //'hello' 2S('hello').padLeft(10).s //' hello' 3S('hello').padLeft(7).s //' hello' 4S('hello').padLeft(6).s //' hello' 5S('hello').padLeft(10, '.').s //'.....hello'
Right pads the string.
Example:
1S('hello').padRight(5).s //'hello' 2S('hello').padRight(10).s //'hello ' 3S('hello').padRight(7).s //'hello ' 4S('hello').padRight(6).s //'hello ' 5S('hello').padRight(10, '.').s //'hello.....'
Parses a CSV line into an array.
Arguments:
delimiter
: The character that is separates or delimits fields. Default: ,
qualifier
: The character that encloses fields. Default: "
escape
: The character that represents the escape character. Default: \
lineDelimiter
: The character that represents the end of a line. When a lineDelimiter is passed the result will be a multidimensional array. Default: undefined
Example:
1S("'a','b','c'").parseCSV(',', "'") //['a', 'b', 'c']) 2S('"a","b","c"').parseCSV() // ['a', 'b', 'c']) 3S('a,b,c').parseCSV(',', null) //['a', 'b', 'c']) 4S("'a,','b','c'").parseCSV(',', "'") //['a,', 'b', 'c']) 5S('"a","b",4,"c"').parseCSV(',', null) //['"a"', '"b"', '4', '"c"']) 6S('"a","b","4","c"').parseCSV() //['a', 'b', '4', 'c']) 7S('"a","b", "4","c"').parseCSV() //['a', 'b', '4', 'c']) 8S('"a","b", 4,"c"').parseCSV(",", null) //[ '"a"', '"b"', ' 4', '"c"' ]) 9S('"a","b\\"","d","c"').parseCSV() //['a', 'b"', 'd', 'c']) 10S('"a","b\\"","d","c"').parseCSV() //['a', 'b"', 'd', 'c']) 11S('"a\na","b","c"\n"a", """b\nb", "a"').parseCSV(',', '"', '"', '\n')) // [ [ 'a\na', 'b', 'c' ], [ 'a', '"b\nb', 'a' ] ]
Returns a string repeated n
times.
Alias: times()
Example:
1S(' ').repeat(5).s; //' ' 2S('*').repeat(3).s; //'***'
Return the new string with all occurrences of ss
replaced with newstr
.
Example:
1S(' does IT work? ').replaceAll(' ', '_').s; //'_does_IT_work?_' 2S('Yes it does!').replaceAll(' ', '').s; //'Yesitdoes!'
Restore the original String prototype. Typically used in conjunction with extendPrototype()
.
Example:
1S.restorePrototype();
Return the substring denoted by n
positive right-most characters.
Example:
1S('I AM CRAZY').right(2).s; //'ZY' 2S('Does it work? ').right(4).s; //'k? ' 3S('Hi').right(0).s; //'' 4S('My name is JP').right(-2).s; //'My', same as left(2)
Alias: toString()
The encapsulated native string representation of an S
object.
Example:
1S('my name is JP.').capitalize().s; //My name is JP. 2var a = "Hello " + S('joe!'); //a = "Hello joe!" 3S("Hello").toString() === S("Hello").s; //true
Sets the string to a value
.
1var myString = S('War'); 2myString.setValue('Peace').s; // 'Peace'
Converts the text into a valid url slug. Removes accents from Latin characters.
1S('Global Thermonuclear Warfare').slugify().s // 'global-thermonuclear-warfare' 2S('Crème brûlée').slugify().s // 'creme-brulee'
Returns an array of strings, split from the left at sep
. Performs at most maxSplit
splits, and slices the result into an array with at most limit
elements.
Example:
1S('We built this city').splitLeft(' '); // ['We', 'built', 'this', 'city']; 2S('We built this city').splitLeft(' ', 1); // ['We', 'built this city']; 3S('On Rock N Roll and other Stuff').splitLeft(' ', -1, 4); // ['On', 'Rock', 'N', 'Roll']; 4S('On Rock N Roll and other Stuff').splitLeft(' ', 5, -2); // ['and', 'other Stuff'];
Returns an array of strings, split from the left at sep
. Performs at most maxSplit
splits, and slices the result into an array with at most limit
elements.
Example:
1S('This is all very fun').splitRight(' '); // ['This', 'is', 'all', 'very', 'fun']; 2S('and I could do it forever').splitRight(' ', 1); // ['and I could do it', 'forever']; 3S('but nothing matters in the end.').splitRight(' ', -1, 2); // ['the', 'end.']; 4S('but nothing matters in the end.').splitRight(' ', 4, -2); // ['but nothing', 'matters'];
Return true if the string starts with prefix
.
Example:
1S('JP is a software engineer').startsWith('JP'); //true 2S('wants to change the world').startsWith('politicians'); //false
Returns a new string with all occurrences of [string1],[string2],...
removed.
Example:
1S(' 1 2 3--__--4 5 6-7__8__9--0').strip(' ', '_', '-').s; //'1234567890' 2S('can words also be stripped out?').strip('words', 'also', 'be').s; //'can stripped out?'
Returns a new string in which all chars have been stripped from the beginning of the string (default whitespace characters).
Example:
1S(' hello ').stripLeft().s; //'hello ' 2S('abcz').stripLeft('a-z').s; //'bcz' 3S('www.example.com').stripLeft('w.').s; //'example.com'
Returns a new string in which all chars have been stripped from the end of the string (default whitespace characters).
Example:
1S(' hello ').stripRight().s; //' hello' 2S('abcz').stripRight('a-z').s; //'abc'
Strip all of the punctuation.
Example:
1S('My, st[ring] *full* of %punct)').stripPunctuation().s; //My string full of punct
Strip all of the HTML tags or tags specified by the parameters.
Example:
1S('<p>just <b>some</b> text</p>').stripTags().s //'just some text' 2S('<p>just <b>some</b> text</p>').stripTags('p').s //'just <b>some</b> text'
Takes a string and interpolates the values. Defaults to {{
and }}
for Mustache compatible templates. However, you can change this default by modifying S.TMPL_OPEN
and S.TMPL_CLOSE
.
Example:
1var str = "Hello {{name}}! How are you doing during the year of {{date-year}}?" 2var values = {name: 'JP', 'date-year': 2013} 3console.log(S(str).template(values).s) //'Hello JP! How are you doing during the year of 2013?' 4 5str = "Hello #{name}! How are you doing during the year of #{date-year}?" 6console.log(S(str).template(values, '#{', '}').s) //'Hello JP! How are you doing during the year of 2013?' 7 8S.TMPL_OPEN = '{' 9S.TMPL_CLOSE = '}' 10str = "Hello {name}! How are you doing during the year of {date-year}?" 11console.log(S(str).template(values).s) //'Hello JP! How are you doing during the year of 2013?'
Returns a string repeated n
times.
Alias: repeat()
Example:
1S(' ').times(5).s //' ' 2S('*').times(3).s //'***'
Returns a string with the first letter of each word uppercased, including hyphenated words
Example:
1S('Like ice in the sunshine').titleCase().s // 'Like Ice In The Sunshine' 2S('data_rate').titleCase().s // 'Data_Rate' 3S('background-color').titleCase().s // 'Background-Color' 4S('-moz-something').titleCase().s // '-Moz-Something' 5S('_car_speed_').titleCase().s // '_Car_Speed_' 6S('yes_we_can').titleCase().s // 'Yes_We_Can 7 8S(' capitalize dash-CamelCase_underscore trim ').humanize().titleCase().s // 'Capitalize Dash Camel Case Underscore Trim'
Converts a a logical truth string to boolean. That is: true
, 1
, 'true'
, 'on'
, or 'yes'
.
JavaScript Note: You can easily convert truthy values to booleans
by prefixing them with !!
. e.g.
!!'hi' === true
or !!'' === false
or !!{} === true
.
Example:
1S('true').toBoolean() //true 2S('false').toBoolean() //false 3S('hello').toBoolean() //false 4S(true).toBoolean() //true 5S('on').toBoolean() //true 6S('yes').toBoolean() //true 7S('TRUE').toBoolean() //true 8S('TrUe').toBoolean() //true 9S('YES').toBoolean() //true 10S('ON').toBoolean() //true 11S('').toBoolean() //false 12S(undefined).toBoolean() //false 13S('undefined').toBoolean() //false 14S(null).toBoolean() //false 15S(false).toBoolean() //false 16S({}).toBoolean() //false 17S(1).toBoolean() //true 18S(-1).toBoolean() //false 19S(0).toBoolean() //false
Converts an array or object to a CSV line.
You can either optionally pass in two string arguments or pass in a configuration object.
String Arguments:
delimiter
: The character that is separates or delimits fields. Default: ,
qualifier
: The character that encloses fields. Default: "
Object Configuration:
delimiter
: The character that is separates or delimits fields. Default: ,
qualifier
: The character that encloses fields. Default: "
escape
: The character that escapes any incline qualifier
characters. Default: \
, in JS this is \\
encloseNumbers
: Enclose number objects with the qualifier
character. Default: true
keys
: If the input isn't an array, but an object, then if this is set to true, the keys will be output to the CSV line, otherwise it's the object's values. Default: false
.Example:
1S(['a', 'b', 'c']).toCSV().s //'"a","b","c"' 2S(['a', 'b', 'c']).toCSV(':').s //'"a":"b":"c"' 3S(['a', 'b', 'c']).toCSV(':', null).s //'a:b:c') 4S(['a', 'b', 'c']).toCSV('*', "'").s //"'a'*'b'*'c'" 5S(['a"', 'b', 4, 'c']).toCSV({delimiter: ',', qualifier: '"', escape: '\\', encloseNumbers: false}).s //'"a\\"","b",4,"c"' 6S({firstName: 'JP', lastName: 'Richardson'}).toCSV({keys: true}).s //'"firstName","lastName"' 7S({firstName: 'JP', lastName: 'Richardson'}).toCSV().s //'"JP","Richardson"'
Return the float value, wraps parseFloat.
Example:
1S('5').toFloat() // 5 2S('5.3').toFloat() //5.3 3S(5.3).toFloat() //5.3 4S('-10').toFloat() //-10 5S('55.3 adfafaf').toFloat() // 55.3 6S('afff 44').toFloat() //NaN 7S(3.45522222333232).toFloat(2) // 3.46
Return the number value in integer form. Wrapper for parseInt()
. Can also parse hex values.
Example:
1S('5').toInt(); //5 2S('5.3').toInt(); //5; 3S(5.3).toInt(); //5; 4S('-10').toInt(); //-10 5S('55 adfafaf').toInt(); //55 6S('afff 44').toInt(); //NaN 7S('0xff').toInt() //255
Alias: s
Return the string representation of an S
object. Not really necessary to use. However, JS engines will look at an object and display its toString()
result.
Example:
1S('my name is JP.').capitalize().toString(); //My name is JP. 2var a = "Hello " + S('joe!'); //a = "Hello joe!" 3S("Hello").toString() === S("Hello").s; //true
Return the string with leading and trailing whitespace removed. Reverts to native trim()
if it exists.
Example:
1S('hello ').trim().s; //'hello' 2S(' hello ').trim().s; //'hello' 3S('\nhello').trim().s; //'hello' 4S('\nhello\r\n').trim().s; //'hello' 5S('\thello\t').trim().s; //'hello'
Return the string with leading and whitespace removed
Example:
1S(' How are you?').trimLeft().s; //'How are you?';
Return the string with trailing whitespace removed.
Example:
1S('How are you? ').trimRight().s; //'How are you?';
Truncates the string, accounting for word placement and character count.
Example:
1S('this is some long text').truncate(3).s //'...' 2S('this is some long text').truncate(7).s //'this is...' 3S('this is some long text').truncate(11).s //'this is...' 4S('this is some long text').truncate(12).s //'this is some...' 5S('this is some long text').truncate(11).s //'this is...' 6S('this is some long text').truncate(14, ' read more').s //'this is some read more'
Returns converted camel cased string into a string delimited by underscores.
Example:
1S('dataRate').underscore().s; //'data_rate' 2S('CarSpeed').underscore().s; //'car_speed' 3S('yesWeCan').underscore().s; //'yes_we_can'
Unescapes the html.
Example:
1S('<div>hi</div>').unescapeHTML().s; //<div>hi</div>
wrapHTML helps to avoid concatenation of element with string. the string will be wrapped with HTML Element and their attributes.
Example:
1S('Venkat').wrapHTML().s //<span>Venkat</span> 2S('Venkat').wrapHTML('div').s //<div>Venkat</div> 3S('Venkat').wrapHTML('div', { 4 "class": "left bullet" 5}).s //<div class="left bullet">Venkat</div> 6S('Venkat').wrapHTML('div', { 7 "id": "content", 8 "class": "left bullet" 9}).s // <div id="content" class="left bullet">Venkat</div>
Returns native JavaScript string containing the version of string.js
.
Example:
1S.VERSION; //1.0.0
decodeHtmlEntities()
converts
to 0xa0 (160) and not 0x10 (20). Most browsers consider 0xa0 to be whitespace characters, Internet Explorer does not despite it being part of the ECMA standard. Google Closure does a good job of normalizing this behavior. This may need to be fixed in string.js
at some point in time.
Install the dev dependencies:
$ npm install string --development
Install mocha globally:
$ npm install -g mocha
Then navigate to the installed directory:
$ cd node_modules/string/
Run test package:
$ mocha test
Click here to run the tests in your web browser.
I have looked at the code by the creators in the libraries mentioned in Motivation. As noted in the source code, I've specifically used code from Google Closure (Google Inc), Underscore String Esa-Matti Suuronen, and php.js (http://phpjs.org/authors/index), Substack and TJ Holowaychuk.
If you contribute to this library, just modify string.js
, string.test.js
, and update README.md
. I'll update the website docs and generate the new string.min.js
, changelog and version.
(You can add your name, or I'll add it if you forget)
chain
function though. https://github.com/jprichardson/string.js/issues/49Licensed under MIT.
Copyright (C) 2012-2016 JP Richardson jprichardson@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Stable Version
1
7.5/10
Summary
Regular Expression Denial of Service in string package
Affected Versions
<= 3.3.3
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 12/27 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More