MaximDevoir/enum-bug

Enumerate bugged properties that will not enumerate in older browsers (i.e. IE 8 and below).

★ 1Forks 1HCLGitHub ↗Compare

README

Enum Bug

Enumerate properties that will not enumerate in older browsers (i.e. IE 8 and below).

license bundlephobia minzip npm dependents downloads Coverage Status Known Vulnerabilities

Installation

npm install enum-bug

Note: use add --save if you are using npm < 5.0.0

Usage

import enumBug from 'enum-bug';

const obj = {
  hello: 'not a bugged property',
  constructor: 'bugged property',
  hasOwnProperty: 'bugged property',
  isPrototypeOf: 'bugged property',
  propertyIsEnumerable: 'bugged property',
  toLocaleString: 'bugged property',
  toString: 'bugged property',
  valueOf: 'bugged property',
  goodbye: 'another normally enumerated property',
};

enumBug(obj, prop => {
  console.log(`${prop} is bugged.`);
});

By executing the code in an environment that contains an object enumeration bug (i.e. Internet Explorer 8 and below), the result will be

// console
 => constructor is bugged
 => hasOwnProperty is bugged
 => isPrototypeOf is bugged
 => propertyIsEnumerable is bugged
 => toLocaleString is bugged
 => toString is bugged
 => valueOf is bugged

Note

The bugged properties are:

  • constructor
  • hasOwnProperty
  • isPrototypeOf
  • propertyIsEnumerable
  • toLocaleString
  • toString
  • valueOf

This module will only enumerate over bugged properties in environments where they would not otherwise be enumerated.

If the environment enumerates object properties properly, then no properties are enumerated.

Contributors

MaximDevoirdependabot[bot]

Issues