2.6.2 • Published 4 years ago

daypack v2.6.2

Weekly downloads
38
License
Apache v2
Repository
github
Last release
4 years ago

daypack

A JavaScript library for flattening and reassembling object graphs.

purpose

This library was written to handle packing up deep JS object graphs to send over the wire. It does this by traversing the entire graph recursively, and packing entities into a flat data structure.

This library is similar to normalizr, but with a few differences:

  • All ids need to be unique.
  • You don't need to define a schema, or know the type of an entity to pack/unpack it.
  • You can use this library to serialize/deserialize JS class instances, as long as you register a custom packer/unpacker for it.

api

Daypack : object

Kind: global namespace


daypack.withHeap ⇒

withHeap allows you to manually set the heap for a pack

Kind: instance property of Daypack
Returns: this
Params

  • heap

daypack.withHead ⇒

withHead allows you to manually set the head for a pack

Kind: instance property of Daypack
Returns: this
Params

  • head

daypack.pack ⇒

pack packs a value into the heap, and updates the head

Kind: instance property of Daypack
Returns: this
Params

  • val

daypack.packHeap ⇒

packHeap packs a value into the heap, but does not update the head

Kind: instance property of Daypack
Returns: this
Params

  • val

daypack.unpack ⇒

unpack unpacks the head, or accepts an optional "head" to unpack

Kind: instance property of Daypack
Returns: the unpacked head
Params

  • val - an optional "head" to use as a base point for unpacking

daypack.each ⇒

each unpacks everything in the heap in isolation, and calls the 'each' function on it

Kind: instance property of Daypack
Returns: this
Params

  • func - an each function to call

daypack.filter ⇒

filter unpacks everything in the heap in isolation, and calls the 'filter' function on it, to build a new pack

Kind: instance property of Daypack
Returns: a new DayPack instance with only the filtered entities in the heap
Params

  • func - a filter function to call

daypack.map ⇒

map unpacks everything in the heap in isolation, and calls the 'map' function on it, to build a new pack

Kind: instance property of Daypack
Returns: a new DayPack instance with the mapped entities in the heap
Params

  • func - a map function to call

daypack.reduce ⇒

reduce unpacks everything in the heap in isolation, and calls the 'reducer' function on it, to build a new reduced result

Kind: instance property of Daypack
Returns: a new DayPack instance with only the filtered entities in the heap
Params

  • func - a filter function to call

daypack.toObject ⇒

toObject converts the pack into a serializable object

Kind: instance property of Daypack
Returns: a serializable version of the pack


daypack.fromObject ⇒

fromObject de-serializes a serialized version into a DayPack instance

Kind: instance property of Daypack
Returns: this
Params

  • obj - the object to unpack

daypack.toJSON ⇒

toJSON converts the pack into a JSON object

Kind: instance property of Daypack
Returns: a JSON string


daypack.fromJSON ⇒

fromJSON de-serialized a JSON string into this pack

Kind: instance property of Daypack
Returns: a JSON string
Params

  • json - the json to unpack

daypack.fromJSON ⇒

fromJSON de-serialized a JSON string into this pack

Kind: instance property of Daypack
Returns: a JSON string
Params

  • json - the json to unpack

Daypack.Daypack

Kind: static class of Daypack


Daypack.clone(val) ⇒

A function that packs a JavaScript value.

Kind: static method of Daypack
Returns: an flattened object
Params

  • val - the value to pack

2.6.1

4 years ago

2.6.0

4 years ago

2.6.2

4 years ago

2.5.0

5 years ago

2.4.3

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago