ChiliJs
Usefuls variables for node env.
Install
NPM
$ npm install chili-js --save
Yarn
$ yarn add chili-js
Features / API
Path
-
#### Shortcuts
path.join()
=>join()
path.parse()
=>parse()
path.normalize()
=>normalize()
path.relative()
=>relative_path()
path.sep
=>separator
-
#### Functions
-
String.prototype.relativeTo()
It returnspath.relative(pth1, pth2)
aspth1.relativeTo(pth2)
;;//=> ../../Documents
JSON Shortcuts
JSON.jparse()
=>jparse()
JSON.jstringify()
=>jstringify()
Console Shortcuts
console.log()
=>log()
console.warn()
=>warn()
console.error()
=>err()
FS Shortcuts
fs.writeFile()
=>write()
fs.writeFileSync()
=>writeSync()
fs.readFile()
=>read()
fs.readFileSync()
=>readSync()
Variables
home
who is the /Users/<user>/
(~
path)
and user
who is the <user>
in ~
path.
Standalone Functions
-
String.prototype.capitalize(divider, joiner)
This function provides to
capitalize
a word....'hello world' //=> 'Hello World'It can also parse a word
...'hello-world' //=> 'Hello-World''hello-world' //=> 'Hello World''hello world'//=> Hello-World -
Array.prototype.sum()
This function provides to
sum
all items in array...1 2 3//=> 6If an item in
array
is not a number it will be ignored....'a' 15 'b' 5 'c'//=> 20