sash

0.0.4 • Public • Published

Sash

Sash is a more refined alternative to ulility belt libraries such as underscore, lodash, mout, and many more. Sash emphasizes composing higher-order expressions instead of pollyfilling javascript objects, which works especially well when dealing with promises and arrays.

$ npm install sash --save

API

As a rule, methods that take arguments are functions, methods that do not take methods are properties.

identity

Always return the same value, no matter the input.

var me = sash.identity('AJ')
[ 1, 2 ].map(me) == [ 'AJ', 'AJ' ]

prop

Try to follow a path of property keys through a json object. Useful for working with external APIs.

var getX = sash.prop('data', 0, 'x');
getX({ data: [ { x: 5, y: 10 } ] }) == 5

pick

Pick properties from an object.

var present = sash.pick('id', 'name');
present({ id: 5, name: 'AJ', age: 20 }) == { id: 5, name: 'AJ' }

squish

Trim the string and replace whitespace with one space.

sash.squish('   hello  world ') == 'hello world'

Chaining

All sash functions and property functions can be chained which pipes the output of the first to the next function.

var object = { input: '  messy ' };
var getName = sash.prop('input').squish;
getName(object) == 'messy'

Notes

Please share ideas and report bugs. Sash should be intuitive and lead to cleaner code. Otherwise it needs improvement!

License: MIT

Readme

Keywords

none

Package Sidebar

Install

npm i sash

Weekly Downloads

0

Version

0.0.4

License

MIT

Last publish

Collaborators

  • aj0strow