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

obj-trans

v1.0.0

Published

module that will run a function/ functions recursively over an object to transform all of the values at any nest level

Downloads

6

Readme

obj-trans

Description: module that will run a function/ functions recursively over an object to transform all of the values at any nest level

Getting Started:

npm install obj-trans --save

example:

objTrans = require('obj-trans');

var testObj = {one:1,two:2,nestOne:{one:1,two:2}};
var testFunction = function(x){return x*2);

return objTrans(testObj,testFunction);

//returns {one:2,two:4,nestOne:{one:2,two:4}}

//second param that takes a function can also take an array of functions.

Method:

objTrans(object,function/functions)

	params:
		object:the object your transforming
		function(functions): either a function or array of functions to run.
		
	return: newly transformed object.
	

Things to note:

  1. when using an array of functions the first function will fully be applied and then the new object will be passed in and transformed with the next until the array is drained.
  2. Remember if calling objTrans on the same object more then once the object is a ref so even though your not storing the return its changing the origional object.
  3. Make sure to type check inside your transform functions because it will be ran on every value regardless of it being a string/number/array.
  4. Arrays are also treated as values...so each value in an array is also ran through transform functions.

Function format:

function(x) { //x is the orig value pre transformation.
	return x*2 //return the orig value transformed.	
}