@basekits/kit-string v1.0.0
@basekits/kit-string
String manipulation and helper functions kit for basekits.
Install
npm i @basekits/kit-type @basekits/kit-object @basekits/kit-stringUsage
const kit = require('@basekits/core')
const type = require('@basekits/kit-type')
const object = require('@basekits/kit-object')
const string = require('@basekits/kit-string')
kit.addKit(type)
kit.addKit(object)
kit.addKit(string)Available Items
The following methods will be available after adding this kit:
.sprintf(str, args)
Replaces %s expressions in the str string with given args in order.
kit.sprintf('Hey %s', 'Murat')
// returns "Hey Murat"
kit.sprintf('Hey %s, you have %s items in your cart.', ['Murat', 4])
// returns "Hey Murat, you have 4 items in your cart.".template(str, props = {})
Replaces {{name}} expressions in a string with given props[name]
kit.template('Hey {{name}}!', {name: 'Murat'})
// returns "Hey Murat!".uppercase(str, locale = undefined)
Capitalize the str. Specify locale (en-US, tr-TR etc.) for locale aware case converting. Uses toLocaleUpperCase native function.
.lowercase(str, locale = undefined)
Lowercase the str. Specify locale (en-US, tr-TR etc.) for locale aware case converting. Uses toLocaleLowerCase native function.
.sentencecase(str, locale = undefined, nouns = [])
Capitalize only the first letter of the first word in given str. Specify locale for locale aware converting. nouns are the list of words that will be excluded while converting.
.titlecase(str, locale = undefined, nouns = [])
Capitalize only the first letter of the words in given str. Specify locale for locale aware converting. nouns are the list of words that will be excluded while converting.
6 years ago