@kingjs/property-descriptor.create-property

1.0.0 • Public • Published

@kingjs/property-descriptor.create-property

Returns an object with a target, a name, and a descriptor which is created by harvesting argument overloads.

Usage

var assert = require('assert')
var createProperty = require('@kingjs/property-descriptor.create-property');

function Type() { };
var prototype = Type.prototype;

// createProperty(target, namedFunction)
var myFunction = function myFunction() { };
var { target, name, descriptor } = createProperty(
  prototype, myFunction
);
assert(target == prototype);
assert(name == 'myFunction');
assert(descriptor.value == myFunction);

// createProperty(target, name, [
//  undef|null|symbol|number|boolean|string|function
// ])
var { target, name, descriptor } = createProperty(
  prototype, 'nonObject', true
);
assert(target == prototype);
assert(name == 'nonObject');
assert(descriptor.value === true);

// createProperty(target, name, descriptor)
var { target, name, descriptor } = createProperty(
  prototype, 'soTrue', { get: true }
);
assert(target == prototype);
assert(name == 'soTrue');
assert(descriptor.get === true);

API

createProperty(target, x, y)

Parameters

  • target: The target on which the property will be declared.
  • x: See the example for a list of overrides.
  • y: See the example for a list of overrides.

Returns

An object with target, name, and descriptor properties where the descriptor properties are harvested from the arguments.

Install

With npm installed, run

$ npm install @kingjs/property-descriptor.create-property

Source

https://repository.kingjs.net/property-descriptor/create-property

License

MIT

Analytics

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/property-descriptor.create-property

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

4.9 kB

Total Files

5

Last publish

Collaborators

  • kingces95