Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including deep-reduce with all npm packages installed. Try it out:

const deepReduce = require('deep-reduce') // let nested leaf values be equal to their path, for demonstration purpose let deepNestedObject = { a: 'a', b: { c: 'b.c' }, c: [ 'c.0', { d: 'c.1.d', e: [ 'c.1.e.0' ] } ] } // store all values which are strings to reduced[path]. let flattenStrings = (reduced, value, path) => { if (typeof value === 'string') { reduced[path] = value } return reduced } // the reduced value is returned let reduced = deepReduce(deepNestedObject, flattenStrings)

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

deep-reduce v1.0.5

reduce objects deeply, call reducer for every nested node in object tree

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free