npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

daypack

v2.6.2

Published

A JavaScript library for flattening and reassembling object graphs.

Downloads

6

Readme

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