progressBar
Generate a progress bar
Parameters
percentage
(number
= 0
)
Percentage (out of 100)
totalSteps
(number
= 10
)
Number of characters
complete
(string
= "█"
)
Character (completed)
empty
(string
= "▒"
)
Character (empty)
Returns
string
: bar
Example
var snu = require('s-node-utils');
snu.others.progressBar(5, 10);
//=> █████▒▒▒▒▒
snu.others.progressBar(44, 50, '!', '|');
//=> !!!!!!!!!!!!!!!!!!!!!!||||||||||||||||||||||||||||
compare
Compare a pure password with hashed password
Parameters
Returns
boolean
: result
Example
var snu = require('s-node-utils');
(async () => {
console.log(
await snu.password.compare(
"F@3Ltv{>=q[8T%,",
"$2a$10$OOJ2FlB56wSEhtwvVQxub.hoiWcEzcFsX2ERdNBo3fSXPSoSPK8zW"
)
);
})();
//=> true
generate
Generate a password
generate(length:
number, lowercase:
boolean, uppercase:
boolean, numbers:
boolean, symbols:
boolean):
string
Parameters
length
(number
= 5
)
Password length
lowercase
(boolean
= true
)
If password contain lowercases
uppercase
(boolean
= true
)
If password contain uppercases
numbers
(boolean
= true
)
If password contain numbers
symbols
(boolean
= false
)
If password contain symbols
Returns
string
: Password
Example
var snu = require('s-node-utils');
snu.password.generate(50, true, true, false, true);
//=> Hnn}VnDySrnlJU.US>}vt<]|@)I^CB/.}|ehxFV_w%f;m,AlJA
hash
Hash a password
Parameters
Returns
string
: Password
Example
var snu = require('s-node-utils');
snu.password.hash("F@3Ltv{>=q[8T%,", 10);
//=> $2a$10$OOJ2FlB56wSEhtwvVQxub.hoiWcEzcFsX2ERdNBo3fSXPSoSPK8zW (exemple)
capitalize
Converts the first string character to uppercase.
Parameters
string
(string)
Character string
Returns
string
: Character string
Example
var snu = require('s-node-utils');
snu.string.capitalize('a text');
//=> A text
chop
Like trim.
Parameters
string
(string)
string
Returns
string
: boolean
Example
var snu = require('s-node-utils');
snu.string.chop('text');
//=> text
snu.string.chop(' text ');
//=> text
snu.string.chop('-text-');
//=> text
shuffle
Mix characters in a string
Parameters
string
(string)
string
Returns
string
: string
Example
ar snu = require('s-node-utils');
snu.string.shuffle("text");
//=> xtet
translate
Translation module
Parameters
string
(string)
string
options
(object
= {to='en'}
)
Option (default: { from = 'auto', to = 'en', raw = false })
Returns
object
: JSON (async function)
Example
var snu = require('s-node-utils');
(async () => {
console.log(
await snu.string.translate("Salut, comment sa va ?", { to: "en" })
);
})();
//=> { text: 'Hi, how are you?',
//=> from:
//=> { language: { didYouMean: false, iso: 'fr' },
//=> text:
//=> { autoCorrected: false,
//=> value: 'Salut, comment [ça] va ?',
//=> didYouMean: true } },
//=> raw: '' }
unzalgo
Removes all Zalgo text characters for every word in a string if the word is zalgo text.
Parameters
Returns
string
: string
Example
var snu = require('s-node-utils');
snu.string.unzalgo('ť͈̓̆h̏̔̐̑ì̭ͯ͞s̈́̄̑͋');
//=> this
zalgolize
Transforms string to zalgo text.
Parameters
Returns
string
: string
Example
var snu = require('s-node-utils');
snu.string.zalgolize('this');
//=> t̋hiͤsͮ