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

jsonbuilddo

v1.0.4

Published

JSON object management utility

Downloads

5

Readme

Table of Contents

jsonBuildDo

Supports a predefined configuration that extends JSONDo to manage JSON objects in a dynamicly

Meta

  • version: 1.0.0
  • author: Justin Mathews

configType

Type defining JSON management instructions

Parameters

  • jsonConfig JSON Object containing all values needed
    • jsonConfig.type String type Object type that will be found in sourceObject ['static', 'json', 'function']
    • jsonConfig.sourceObject any Object type passed, must match that defined by "type". Except when type = "static", then the object will be returned as is
    • jsonConfig.sourcePath (String | Array | Undefined) This will either be a (type = 'json') dot '.' delimited string mapping the path to the value (type = 'function') an Array of parameters to pass to the function or Undefined (type = 'static') Undefined - value will be ignored
    • jsonConfig.newPath String dot '.' delimited string mapping the path to the value

getValue

  • See: configType

Returns a value based on the configuration passed. This can a static value or one collected from a JSON object or function call

Parameters

  • type
  • sourceObject
  • sourcePath
  • jsonConfig JSON Object containing all values needed
    • jsonConfig.type String type Object type that will be found in sourceObject ['static', 'json', 'function']
    • jsonConfig.sourceObject any Object type passed, must match that defined by "type". Except when type = "static", then the object will be returned as is
    • jsonConfig.sourcePath (String | Array | Undefined) This will either be a (type = 'json') dot '.' delimited string mapping the path to the value (type = 'function') an Array of parameters to pass to the function or Undefined (type = 'static') Undefined - value will be ignored

Examples

Retrieve a STATIC value 
getValue('static', 'some value', undefined) => 'some value' * 
getValue('static', 'some value') => 'some value'
Retrieve a value from JSON
getValue('json', {a:{b:1,c:{d:'value here'}}}, 'a.c.d') => 'value here'
Retrieve value from function call
getValue('function', function bob(){ return 'a value from funtion'}, undefined) => 'a value from funtion'
getValue('function', (input)=>{ return input + 10}, [1]) => 11
getValue('function', (input1, input2)=>{ return input1 + input2}, [1, 100]) => 101
Pass configuration in as JSON object instead of individual parameters
let json = {type: 'static', sourceObject: 'parameters passed in json', sourcePath: undefined}
getValue(json) => 'parameters passed in json'

Returns any

buildBranch

  • See: configType

Creates a new JSON object based using a dot '.' delimited String and a value is assign after having retrieved it from the location passed

Parameters

  • jsonConfig JSON A combination of TYPE configType with an additional field "newPath"
    • jsonConfig.type String
    • jsonConfig.sourceObject any
    • jsonConfig.sourcePath (Sting | Array | Undefined)
    • jsonConfig.newPath String A dot '.' delimited string that maps the path of the new JSON object

Examples

Using the same process as shown in getValue, an additional step will be added to define and create a nw JSON object with the value provided
let jsonConfig = {type: 'static', sourceObject: 42, newPath: 'answer.to.life.is'}
buildBranch(jsonConfig) => {answer: {to: {life: {is: 42}}}}
Same as above, but the parameters are passed seperately
buildBranch('static', 42, undefined, 'answer.to.life.is') => {answer: {to: {life: {is: 42}}}}

Returns JSON