help-string v0.1.0
help-string
Small js package I use to help me to dealing with strings
Install
$ npm install help-string
Import
This package is pure ESM. It cannot be require()
'd from CommonJS.
Use import foo from 'foo'
instead of const foo = require('foo')
to import the package.
// Load entire build
import * as helpString from 'help-string';
// Load by method
import {sliceText} from 'help-string';
If the package is used in an async context, you could use await import(…)
from CommonJS instead of require(…)
.
You also need to make sure you're on the latest minor version of Node.js. At minimum Node.js 12.20, 14.14, or 16.0.
Read more here: sindresorhus/esm-package
Usage
helpString.isMail('');
//=> false
helpString.isEmpty('')
//=> true
startsWith
: Checks if string
starts with the given target string.
endsWith
: Checks if string
ends with the given target string.
indexOf
: Find the index of a given string inside another.
isEmpty
: Check if given string is undefined, null, or zero length.
isImageUrl
: Checks if value is a valid image url.
isMail
: Checks if value is a valid mail.
isPhone
: Checks if value is a valid phone number.
isUrl
: Checks if value is a valid url.
random
: Generates a random string.
repeat
: Repeats the given string n
times.
replace
: Replaces matches for pattern
in string
with replacement
.
sliceText
: Split text and keep n
many characters.
License
MIT © Paul Nodet
3 years ago