0.0.8 • Published 9 years ago

delvec v0.0.8

Weekly downloads
2
License
ISC
Repository
github
Last release
9 years ago

delvec

A small curried library for fetching properties from objects.

Get properties from JSON.

json = {
  "name": "Foo"
};

var fromJson = delvec(json);

fromJson('name');    // 'Foo'
fromJson('a.b.c');   // undefined

It also works in reverse order.

json = [
  { "name": "Foo" },
  { "name": "Bar" },
  { "name": "Baz" }
];

var name = delvec('name');

name(json[0]);    // 'Foo'
name(json[1]);    // 'Bar'
name(json[2]);    // 'Baz'

Set defaults if delvec is empty handed.

json = [
  { "name": "Foo", order: 1 },
  { "name": "Bar", order: 2 },
  { "name": "Baz" }
];

var order = delvec.or(0, 'order');

order(json[0]);    // 1
order(json[1]);    // 2
order(json[2]);    // 0
0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.50

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago