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

@magic/deep

v0.1.16

Published

manipulate nested objects and arrays

Downloads

1,584

Readme

@magic/deep

Work with deeply nested objects and arrays.

NPM version Linux Build Status Windows Build Status Coverage Status Greenkeeper badge Known Vulnerabilities

install
npm i --save --save-exact @magic/deep
import
// single function
import { equal, flatten, loop, merge } from '@magic/deep'

// object with all functions
import deep from '@magic/deep'

Currently implemented:

deep.equal
// test equality
deep.equal(['shallow', ['deep']], ['shallow', ['deep']])
// true

// alias
deep.equals, deep.eq
deep.different
// test difference
deep.different(['shallow', ['deep']], ['shallow', ['deep']])
// false

// alias
deep.diff
deep.flatten
// flatten a deeply nested array
deep.flatten(['shallow', ['deep']])
// ['shallow', 'deep']
deep.loop
// apply function add
const add = e => e + 1

// for each item
const items = [1, 2, [3]]

// using a deeply nested array
deep.loop(add, items)
// or
deep.loop(items, add)
// returns [2, 3, [4]]
deep.merge
// merge objects and arrays, with infinite recursion if needed.
// this can be slow...

deep.merge({ obj1Key: { val: 1 } }, { obj2Key: { val: 2 } })

// { obj1Key: { val: 1}, obj2Key: { val: 2 } }

deep.merge({ key: { val: 1, str: 'test' } }, { key: { val: 2, str: 'overwritten' } })

// { key: { val: 2, str: 'overwritten' } }

Changelog

0.1.0

use ecmascript modules instead of commonjs.

0.1.1

  • update readme
  • also export deep.eq alias for deep.equal

0.1.2

  • require node 13.5.0
  • use deep.equal and deep.different from @magic/types

0.1.3

bump required node version to 14.2.0

0.1.4

update dependencies

0.1.5

  • bump required node version to 14.15.4
  • update dependencies
0.1.6
  • merge now checks if o2.hasOwnProperty is a function before using it to check if we should overwrite keys of o1 or not.
0.1.7

update @magic/types to avoid circular dependency

0.1.8
  • update dependencies
  • use @magic/types for all type comparisons
0.1.9

update dependencies

0.1.10

update dependencies

0.1.11

update dependencies

0.1.12

update dependencies

0.0.13

update dependencies

0.0.14

update dependencies

0.0.15

update dependencies

0.0.16

update dependencies

0.0.17 - unreleased

...