@dannyfranca/handsome-helpers
v0.4.1
Published
Time-saving helpers for JavaScript and TypeScript
Downloads
3
Readme
@dannyfranca/js-handsome-helpers
Time-saving helpers for JavaScript and TypeScript.
Install
npm install @dannyfranca/handsome-helpers
Usage
Default
import helpers from '@dannyfranca/handsome-helpers'
const opt = helpers.optionsFromString('x:foo|y:bar')
console.log(opt) // { x: 'foo', y: 'bar' }
or
import anyMethod from '@dannyfranca/handsome-helpers/lib/helpers/anyMethod'
Proxyed
import helpers from '@dannyfranca/handsome-helpers/lib/proxyhelpers'
// Works just right the defaults
const opt = helpers.optionsFromString('x:foo|y:bar')
console.log(opt) // { x: 'foo', y: 'bar' }
####But now you can add and merge your custom helpers
Adding/Overwriting
import helpers from '@dannyfranca/handsome-helpers/lib/proxyhelpers'
// with chainable method $add
helpers
.$add('customHelper1', function(...args) {
// ...
})
.$add('customHelper2', function(...args) {
// ...
})
//directly
helpers.customHelpers = function(...args) {
// ...
}
// Dont try to name with $, with throw an Error
helpers.$customHelpers = function(...args) {
// ...
}
Merging
import helpers from '@dannyfranca/handsome-helpers/lib/proxyhelpers'
helpers.$merge({
customHelper() {
// ...
},
// ...
})
Methods
To see a list of use cases and expected results, look at the test folder.
License
Copyright (c) Danny França [email protected]