pytils: functions utils like python
many functions that use to simplify my javascript and that the syntax is inspired by python and ramda
I will help if you have any difficulty =)
Contact me by github:heyderpd. I'll be glad to help you.
npm~lucasmreis
Thanks fornpm install --save pytils
Example:
const p = require('pytils') p.compose = function ( _arrayOfFunctions ) // return function waiting for inputp.curry = function ( _function ) // return function waiting for inputp.path [curry] = function ( _arrPathOfProps, _object ) // return prop of _object in path or undefinedp.reduce = ( _object , fx ) // do each of any type, pass to function var's (key, value) to return a value p.copy = ( _object ) // copy any typesp.length = ( _object ) // get length of any type, return -1 if can'tp.keys = ( _object ) // get keys of any type, return [] if can'tp.values = ( _object ) // get values of any type, return [] if can'tp.hasProp = ( _object , prop ) // of any type, return true or false p.type = function ( _object ) // return type of var in a stringp.isType = function ( _object , _type_need) // return true or falsep.isString = function ( _object ) // return true or falsep.isNumber = function ( _object ) // return true or falsep.isArray = function ( _object ) // return true or falsep.isObject = function ( _object ) // return true or falsep.isFunction = function ( _object ) // return true or falsep.isAOF = function ( _object ) // return true or false if is isArray OR isObject OR isFunctionp.isNull = function ( _object ) // return true or falsep.isUndefined = function ( _object ) // return true or false p.toObject = ( _array ) // convert array to object, return object have values of array in keys of objectp.arrayDiff = ( _array base , _array compare ) // compare two array and return the diff values of basep.invertObj = ( _object ) // convert object keys in value and value in keysp.uniq = ( _array ) // get unique values of array, work with simple var'sp.eq1True = ( _array ) // if is a array of one value of true, return truep.uniqWith = ( _comparator, _array ) // foreach array and return unique itens with comparatorp.uniqObject = ( _objectA, _objectB ) // compare all prop of two object and return if is equalp.ojbFromVals = ( _array ) // create object from array valuesp.ifThrow = ( bool, string ) // trow text erro if bool is true var _function = function( key, value ) { console.log('item: ', keys, ' = ', value) }p.map [curry] = ( _function , _object ) // do each of any type, pass to function var's (key, value)p.mapx = ( _object , _function ) // do each of any type, pass to function var's (key, value) var _dictionary = { toA, 'fromB', toC: 'fromD' }p.translate [curry] = ( _dictionary, _array ) // translate object using dictionary of props