Extends proto-list with a 'deepSnapshot'

npm install proto-list-deep
3 downloads in the last week
6 downloads in the last month


An extension of isaacs' proto-list that exposes a deepSnapshot. This returns a different result than snapshot. Whereas snapshot is implicitly merging all keys at the top level due to the prototype chain, deepSnapshot first flattens each 'level' of the proto-list, grabs all the values, then unflattens the result back to its original depth.

Proto-list-deep does not disturb any of proto-list's functionality (and passes all of proto-list's tests), so you can use it in place of proto-list if you wish.

Important Caveat

Proto-list-deep flattens the objects by concatenating keys together with a delimeter. By default it uses :. So, your object keys CANNOT contain this delimeter, else the unflattening will fail. You can change this delimeter in the ProtoListDeep() constructor.


var ProtoListDeep = require('proto-list-deep');
var p = new ProtoListDeep();

  fruit: { green: 'apple' }
  fruit: { green: 'lime', yellow: 'lemon' }

// { fruit: { green: 'apple' } }

// { fruit: { green: 'apple', yellow: 'lemon' } }
npm loves you