New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

daypack

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daypack

A JavaScript library for flattening and reassembling object graphs.

latest
Source
npmnpm
Version
2.6.2
Version published
Maintainers
1
Created
Source

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

Keywords

object

FAQs

Package last updated on 28 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts