make-enumerable

Make all the properties of an object enumerable. Optionally deep, shallow by default.


Keywords
define, define-property, enumerable, key, non, non-enumerable, object, prop, property, value
License
MIT
Install
npm install make-enumerable@0.2.0

Documentation

make-enumerable NPM version

Make all the properties of an object enumerable. Optionally deep, shallow by default.

Install

Install with npm

$ npm i make-enumerable --save

Usage

var makeEnumerable = require('make-enumerable');
var delegate = require('delegate-properties');

var initial = {
  upper: function(val) {
    return val.toUpperCase();
  },
  lower: function(val) {
    return val.toLowerCase();
  }
};

// make a copy of initial, and make properties non-enumerable
var obj = delegate({}, initial);
console.log(obj.upper) // [function]
console.log(obj.lower) // [function]
console.log(obj); // {}
console.log(Object.keys(obj)); // []

// now, let's make the properties enumerable again
makeEnumerable(obj);

console.log(obj); // {upper: [function], lower: [function]}
console.log(Object.keys(obj)); // ['upper', 'lower']

nested objects

To make properties on nested objects enumerable, pass true as the second argument:

makeEnumerable(obj, true);

Related projects

  • define-property: Define a non-enumerable property on an object.
  • delegate-properties: Deep-clone properties from one object to another and make them non-enumerable, or make existing properties… more
  • delegate-object: Copy properties from an object to another object, where properties with function values will be… more
  • forward-object: Copy properties from an object to another object, where properties with function values will be… more
  • mixin-deep: Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.
  • mixin-object: Mixin the own and inherited properties of other objects onto the first object. Pass an… more

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on August 16, 2015.