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

reftools

v1.1.9

Published

Utility functions to deal with references in objects

Downloads

5,956,997

Readme

RefTools

Functions

Typedefs

nop(obj) ⇒

a no-op placeholder which returns the given object unchanged useful for when a clone function needs to be passed but cloning is not required

Kind: global function
Returns: the input object, unchanged

| Param | Description | | --- | --- | | obj | the input object |

clone(obj) ⇒

clones the given object using JSON.parse and JSON.stringify

Kind: global function
Returns: the cloned object

| Param | Description | | --- | --- | | obj | the object to clone |

shallowClone(obj) ⇒

clones the given object's properties shallowly, ignores properties from prototype

Kind: global function
Returns: the cloned object

| Param | Description | | --- | --- | | obj | the object to clone |

deepClone(obj) ⇒

clones the given object's properties deeply, ignores properties from prototype

Kind: global function
Returns: the cloned object

| Param | Description | | --- | --- | | obj | the object to clone |

fastClone(obj) ⇒

clones the given object's properties shallowly, using Object.assign

Kind: global function
Returns: the cloned object

| Param | Description | | --- | --- | | obj | the object to clone |

circularClone()

Source: stackoverflow http://bit.ly/2A1Kha6

Kind: global function

dereference(o) ⇒

dereferences the given object

Kind: global function
Returns: the dereferenced object
Definitions: a source of definitions to reference
Options: optional settings (used recursively)

| Param | Description | | --- | --- | | o | the object to dereference |

flatten(obj, callback) ⇒

flattens an object into an array of properties

Kind: global function
Returns: the flattened object as an array of properties

| Param | Description | | --- | --- | | obj | the object to flatten | | callback | a function which can mutate or filter the entries (by returning null) |

jpescape(s) ⇒

escapes JSON Pointer using ~0 for ~ and ~1 for /

Kind: global function
Returns: the escaped string

| Param | Description | | --- | --- | | s | the string to escape |

jpunescape(s) ⇒

unescapes JSON Pointer using ~0 for ~ and ~1 for /

Kind: global function
Returns: the unescaped string

| Param | Description | | --- | --- | | s | the string to unescape |

jptr(obj, prop, newValue) ⇒

from obj, return the property with a JSON Pointer prop, optionally setting it to newValue

Kind: global function
Returns: the found property, or false

| Param | Description | | --- | --- | | obj | the object to point into | | prop | the JSON Pointer or JSON Reference | | newValue | optional value to set the property to |

recurse(object, state, callback)

recurses through the properties of an object, given an optional starting state anything you pass in state.payload is passed to the callback each time

Kind: global function

| Param | Description | | --- | --- | | object | the object to recurse through | | state | optional starting state, can be set to null or | | callback | the function which receives object,key,state on each property |

reref(obj, options) ⇒

Simply modifies an object to have no self-references by replacing them with $ref pointers

Kind: global function
Returns: the re-referenced object (mutated)

| Param | Description | | --- | --- | | obj | the object to re-reference | | options | may contain a prefix property for the generated refs |

objToGraph(obj, containerName) ⇒

Takes an object and creates a graph of JSON Pointer / References

Kind: global function
Returns: the graph suitable for passing to toposort()

| Param | Description | | --- | --- | | obj | the object to convert | | containerName | the property containing definitions. Default: definitions |

visit(obj, comparison, callbacks) ⇒

Given an expanded object and an optional object to compare to (e.g. its $ref'd form), will call the following functions:

  • callbacks.before - lets you modify the initial starting state, must return it
  • callbacks.where - lets you select a subset of properties, return a truthy value
  • callbacks.filter - called for all selected properties, can mutate/remove (by setting to undefined)
  • callbacks.compare - allowing the objects to be compared by path (i.e. for $ref reinstating)
  • callbacks.identity - called on any object identity (previously seen) properties
  • callbacks.selected - called for all selected/unfiltered properties, does not mutate directly
  • callbacks.count - called at the end with the number of selected properties
  • callbacks.finally - called at the end of the traversal

Kind: global function
Returns: the possibly mutated object

| Param | Description | | --- | --- | | obj | the object to visit | | comparison | optional object to compare to | | callbacks | object containing functions as above |

Result ⇒ Result

Try to get a topological sorting out of directed graph.

Kind: global typedef

| Param | Type | Description | | --- | --- | --- | | nodes | Object | A list of nodes, including edges (see below). |

Properties

| Name | Type | Description | | --- | --- | --- | | sort | array | the sort, empty if not found | | nodesWithEdges, | array | will be empty unless a cycle is found |