0.0.1 • Published 6 years ago

lakca-helper v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

helper

some helper functions.

Build Status codecov GitHub issues GitHub stars

Documentation

API

assignWithin

const obj = helper.assignWithin({}, {
    a: 1,
    b: 2,
    c: 3
  }, [
    'a', 
    ['b', 'x'], 
    ['c', 'c', v => v + 1]
  ]);
/*
  obj = {
    a: 1,
    x: 2,
    c: 4
  }
 */

assignWithout

const obj = helper.assignWithout({}, {
    a: 1,
    b: 2,
    c: 3
  }, ['c']);
/*
  obj = {
    a: 1,
    b: 2
  }
 */

convert

const obj = helper.convert({
    a: 1,
    b: 2,
    c: 3
  }, [
    ['c', v => v + 1]
  ]);
/*
  obj = {
    a: 1,
    b: 2,
    c: 4
  }
 */

deundefined

const obj = helper.deundefined({
    a: 1,
    b: 2,
    c: undefined
  });
/*
  obj = {
    a: 1,
    b: 2
  }
 */

deempty

const obj = helper.deempty({
    a: 1,
    b: 2,
    c: {}
  });
/*
  obj = {
    a: 1,
    b: 2
  }
 */

ownKeys

same as Reflect.ownKeys in es6 spec.

const c = Symbol('sym');
const keys = helper.ownKeys({
    a: 1,
    b: 2,
    [c]: 3 
  });
/*
  keys = ['a', 'b', c];
 */

Dependency

None

License

MIT