d

WebJar for d

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

d
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

d
WebJar for d
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/medikoo/d

Download d

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : es5-ext jar [0.10.50,0.11)
org.webjars.npm : type jar [1.0.1,2)

Project Modules

There are no modules declared in this project.

Build status Windows status Transpilation status npm version

d

Property descriptor factory

Originally derived from d package.

Defining properties with descriptors is very verbose:

var Account = function () {};
Object.defineProperties(Account.prototype, {
  deposit: {
    value: function () {
      /* ... */
    },
    configurable: true,
    enumerable: false,
    writable: true
  },
  withdraw: {
    value: function () {
      /* ... */
    },
    configurable: true,
    enumerable: false,
    writable: true
  },
  balance: {
    get: function () {
      /* ... */
    },
    configurable: true,
    enumerable: false
  }
});

D cuts that to:

var d = require("d");

var Account = function () {};
Object.defineProperties(Account.prototype, {
  deposit: d(function () {
    /* ... */
  }),
  withdraw: d(function () {
    /* ... */
  }),
  balance: d.gs(function () {
    /* ... */
  })
});

By default, created descriptor follow characteristics of native ES5 properties, and defines values as:

{ configurable: true, enumerable: false, writable: true }

You can overwrite it by preceding value argument with instruction:

d("c", value); // { configurable: true, enumerable: false, writable: false }
d("ce", value); // { configurable: true, enumerable: true, writable: false }
d("e", value); // { configurable: false, enumerable: true, writable: false }

// Same way for get/set:
d.gs("e", value); // { configurable: false, enumerable: true }

Installation

$ npm install d

To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: Browserify, Webmake or Webpack

Other utilities

autoBind(obj, props) (d/auto-bind)

Define methods which will be automatically bound to its instances

var d = require('d');
var autoBind = require('d/auto-bind');

var Foo = function () { this._count = 0; };
Object.defineProperties(Foo.prototype, autoBind({
  increment: d(function () { ++this._count; });
}));

var foo = new Foo();

// Increment foo counter on each domEl click
domEl.addEventListener('click', foo.increment, false);

lazy(obj, props) (d/lazy)

Define lazy properties, which will be resolved on first access

var d = require("d");
var lazy = require("d/lazy");

var Foo = function () {};
Object.defineProperties(Foo.prototype, lazy({ items: d(function () { return []; }) }));

var foo = new Foo();
foo.items.push(1, 2); // foo.items array created and defined directly on foo

Tests

$ npm test

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.


Get professional support for d with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Versions

Version
1.0.1
1.0.0
0.1.1