Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A collection of utility functions for working with strings in JavaScript in the browser or CommonJS.
npm install slang
The annotated source code for slang, generated by Docco, can be found here.
Returns whether input
is a string
slang.isString('testing'); // true
slang.isString(543); // false
Capitalizes the first character of a string
slang.capitalize('hello world!'); // "Hello world!"
Uncapitalizes the first character of a string
slang.uncapitalize('Hello world!); // "hello world!"
Capitalizes each word in the string
slang.capitalizeWords('hello world!'); // "Hello world!"
Uncapitalizes each word in the string
slang.uncapitalizeWords('Hello World!'); // "hello world!"
Returns whether the character at the provided character index is upper case.
slang.isUpperCaseAt('Testing', 0); // true
Returns whether the character at the provided character index is lower case.
slang.isLowerCaseAt('Testing', 1); // true
Inverts the case for each letter in the string
slang.swapcase('aaBBccDD'); // "AAbbCCdd"
Converts a string of words seperated by dashes or spaces to camelCase
slang.camelize('hello world'); // "helloWorld"
slang.camelize('hello-world'); // "helloWorld"
Converts a string of words or a camelCased string into a series of words separated by a dash (-
)
slang.dasherize('this is dashed'); // "this-is-dashed"
Concatinates the string count
times
slang.repeat('Ho! ', 3); // "Ho! Ho! Ho! "
Inserts string
in input
at index
slang.insert('this is cool!', 'really ', 8); // "this is really cool!"
Removes the characters between the start
and end
indexes
slang.remove('this is really cool!', 8, 15); // "this is cool!"
Removes the last character of input
slang.chop('hello'); // "hell"
Removes leading and trailing whitespace from input
. Uses ES5's native trim is available.
slang.trim('hello '); // "hello"
Removes the leading whitespace from input
slang.trimLeft(' hello '); // "hello "
Remove the trailing whitespace from input
slang.trimRight(' hello '); // " hello"
Joins an array into a humanized list. The last element is joined by "and" by default, but you can change it.
slang.join(['red', 'blue', 'green']); // "red, blue and green"
slang.join(['red', 'blue', 'green'], 'or'); // "red, blue or green"
Returns whether input
contains string
slang.contains('hello world', 'world'); // true
Returns whether input
starts with string
slang.startsWith('hello world', 'hello'); // true
Returns whether input
ends with string
slang.endsWith('hello world', 'world'); // true
Returns whether input
is empty or only contains whitespace
slang.isBlank(' '); // true
slang.isBlank(''); // true
Returns the successor to str. The successor is calculated by incrementing characters starting from the rightmost alphanumeric (or the rightmost character if there are no alphanumerics) in the string. Incrementing a digit always results in another digit, and incrementing a letter results in another letter of the same case.
If the increment generates a carry, the character to the left of it is incremented. This process repeats until there is no carry, adding an additional character if necessary.
slang.successor("abcd"); // "abce"
slang.successor("THX1138"); // "THX1139"
slang.successor("<<koala>>"); // "<<koalb>>"
slang.successor("1999zzz"); // "2000aaa"
slang.successor("ZZZ9999"); // "AAAA0000"
Returns a unique guid of the specified length, or 32 by default
slang.guid(); // "gE9FEtJknQVy3qkN9fxmTucYKTwFOno2"
slang.guid(15); // "b0apU4OH7ZgmEoU"
slang is licensed under the MIT license.
FAQs
A collection of utility functions for strings
The npm package slang receives a total of 27,702 weekly downloads. As such, slang popularity was classified as popular.
We found that slang demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.