define-properties

WebJar for define-properties

License

License

MIT
GroupId

GroupId

org.webjars.bowergithub.ljharb
ArtifactId

ArtifactId

define-properties
Last Version

Last Version

1.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

define-properties
WebJar for define-properties
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/ljharb/define-properties

Download define-properties

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.ljharb/define-properties/ -->
<dependency>
    <groupId>org.webjars.bowergithub.ljharb</groupId>
    <artifactId>define-properties</artifactId>
    <version>1.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.ljharb/define-properties/
implementation 'org.webjars.bowergithub.ljharb:define-properties:1.1.2'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.ljharb/define-properties/
implementation ("org.webjars.bowergithub.ljharb:define-properties:1.1.2")
'org.webjars.bowergithub.ljharb:define-properties:jar:1.1.2'
<dependency org="org.webjars.bowergithub.ljharb" name="define-properties" rev="1.1.2">
  <artifact name="define-properties" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.ljharb', module='define-properties', version='1.1.2')
)
libraryDependencies += "org.webjars.bowergithub.ljharb" % "define-properties" % "1.1.2"
[org.webjars.bowergithub.ljharb/define-properties "1.1.2"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.bowergithub.manuelstofer : foreach jar [2.0.5,3)
org.webjars.bowergithub.ljharb : object-keys jar [1.0.8,2)

Project Modules

There are no modules declared in this project.

define-properties Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

Define multiple non-enumerable properties at once. Uses Object.defineProperty when available; falls back to standard assignment in older engines. Existing properties are not overridden. Accepts a map of property names to a predicate that, when true, force-overrides.

Example

var define = require('define-properties');
var assert = require('assert');

var obj = define({ a: 1, b: 2 }, {
	a: 10,
	b: 20,
	c: 30
});
assert(obj.a === 1);
assert(obj.b === 2);
assert(obj.c === 30);
if (define.supportsDescriptors) {
	assert.deepEqual(Object.keys(obj), ['a', 'b']);
	assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'c'), {
		configurable: true,
		enumerable: false,
		value: 30,
		writable: false
	});
}

Then, with predicates:

var define = require('define-properties');
var assert = require('assert');

var obj = define({ a: 1, b: 2, c: 3 }, {
	a: 10,
	b: 20,
	c: 30
}, {
	a: function () { return false; },
	b: function () { return true; }
});
assert(obj.a === 1);
assert(obj.b === 20);
assert(obj.c === 3);
if (define.supportsDescriptors) {
	assert.deepEqual(Object.keys(obj), ['a', 'c']);
	assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'b'), {
		configurable: true,
		enumerable: false,
		value: 20,
		writable: false
	});
}

Tests

Simply clone the repo, npm install, and run npm test

Versions

Version
1.1.2