delvec

0.0.8 • Public • Published

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.81latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.81
0.0.70
0.0.60
0.0.500
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i delvec

Weekly Downloads

1

Version

0.0.8

License

ISC

Last publish

Collaborators

  • luk3thomas