Sha256: f3017ee04c85c77ff0c97c023a900984e5037c9ba4d23e61f2a42fbc36a5759d

Contents?: true

Size: 988 Bytes

Versions: 71

Compression:

Stored size: 988 Bytes

Contents

/*!
 * is-data-descriptor <https://github.com/jonschlinkert/is-data-descriptor>
 *
 * Copyright (c) 2015, Jon Schlinkert.
 * Licensed under the MIT License.
 */

'use strict';

var typeOf = require('kind-of');

// data descriptor properties
var data = {
  configurable: 'boolean',
  enumerable: 'boolean',
  writable: 'boolean'
};

function isDataDescriptor(obj, prop) {
  if (typeOf(obj) !== 'object') {
    return false;
  }

  if (typeof prop === 'string') {
    var val = Object.getOwnPropertyDescriptor(obj, prop);
    return typeof val !== 'undefined';
  }

  if (!('value' in obj) && !('writable' in obj)) {
    return false;
  }

  for (var key in obj) {
    if (key === 'value') continue;

    if (!data.hasOwnProperty(key)) {
      continue;
    }

    if (typeOf(obj[key]) === data[key]) {
      continue;
    }

    if (typeof obj[key] !== 'undefined') {
      return false;
    }
  }
  return true;
}

/**
 * Expose `isDataDescriptor`
 */

module.exports = isDataDescriptor;

Version data entries

71 entries across 38 versions & 12 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
disco_app-0.18.0 test/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
disco_app-0.18.2 test/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
disco_app-0.16.1 test/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
disco_app-0.15.2 test/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
disco_app-0.18.4 test/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
disco_app-0.18.1 test/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
disco_app-0.14.0 test/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
tang-0.2.1 spec/tang_app/node_modules/define-property/node_modules/is-data-descriptor/index.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/define-property/node_modules/is-data-descriptor/index.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/define-property/node_modules/is-data-descriptor/index.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/define-property/node_modules/is-data-descriptor/index.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/define-property/node_modules/is-data-descriptor/index.js
tang-0.2.0 spec/tang_app/node_modules/define-property/node_modules/is-data-descriptor/index.js
tang-0.1.0 spec/tang_app/node_modules/define-property/node_modules/is-data-descriptor/index.js
tang-0.0.9 spec/tang_app/node_modules/define-property/node_modules/is-data-descriptor/index.js
enju_library-0.3.8 spec/dummy/node_modules/define-property/node_modules/is-data-descriptor/index.js
ilog-0.4.1 node_modules/is-data-descriptor/index.js