buryjs
v0.6.0
Published
Ruby-like methods for JavaScript.
Downloads
4
Readme
Bury.js
v0.6
Ruby-like methods for JavaScript.
Bury.js extends the prototype of native JS objects such as String, Number and Array.
Example
[3, 3, 4, null].compact.uniq.sum // => 7
[1, 2, 3, 4].append(5).last // => 5
"Hello!".upcase.chop.reverse // => "OLLEH"
"Bury.js".gsub(/\./, '').size // => 6
3.5.floor.next // => 4
3..times(n => alert(n)) // => Try it out!
Getting Started
npm i buryjs
# or
yarn add buryjs
import Bury from 'buryjs';
Bury.init(options);
If not specified, the options will be set as follows:
options = {
configurable: true,
enumerable: false
};
You can also use the Bury methods only for a specific type of prototype by specifying an array for 'options.only' as follows:
Bury.init({
only: [Array, String]
});
Note: All of Bury's destructive methods will be changed to non-destructive methods in a future version.