medikoo / d Goto Github PK
View Code? Open in Web Editor NEWProperty descriptor factory
License: ISC License
Property descriptor factory
License: ISC License
This package has been removed from NPM. Caused our production builds to fail.
According to this comment, that has been resolved in the ext
package, but I am using a library that relies on d
which in turn relies on the legacy package.
Yes, this is a bug in Vite and they are on it (vitejs/vite#2432), but for now I am blocked by this. Could you update the dependency?
So it's more self explanatory
.
Using d/lazy
is a little confusing for me. Usually, when I define a getter using d
, I use d.gs
, like this:
function Person(name) {
this._name = name;
}
Object.defineProperties(Person.prototype, {
name: d.gs(function () {
return this._name;
})
});
(new Person('michael')).name; // "michael"
However, if I use d/lazy
I can't use d.gs
to define getters anymore. Now, I have to define my properties using d
, which I normally use for defining functions.
function Person(name) {
this._name = name;
}
Object.defineProperties(Person.prototype, lazy({
name: d(function () { // note the use of `d` here instead of `d.gs`
return this._name;
})
}));
(new Person('michael')).name(); // TypeError: Property 'name' of object #<Person> is not a function
(new Person('michael')).name; // "michael"
Ideally I wouldn't have to change the style that I use to declare getters if I wrap my properties in d/lazy
.
d should have bumped a major version for this breaking change.
I know semver says 0.x == do whatever, but it's be nice if more people were comfortable with regularly bumping major versions even if they don't consider their module 'stable'. in fact, semver helps the most when your module isn't stable.
Currently the package.json
has a version of 1.0.0
, while the latest release currently is 0.1.1. Could you please tag the commit and also deploy a new version on NPM? Thanks in advance.
It should work similiarly to cacheName
of lazy
util, so allow functionality to work cross deep prototype chains, and not just on first level.
It needs to be discussed which configuration method is more dev friendly.
Possibly having option named deepLevel
with default to false
will make more sense in both utils, and cacheName by default should be name prefixed with $
(eventually additionally configurable)
Currently it's copied from descriptor by which lazy property was definied, but that characteristics possibly best would if used just for prototype.
And default for instances should be that those properties are enumerable.
If lazy property resolver is async we may automatically remove cached value if promise it resolved with was rejected (it could be overridable via some option)
When overriding existing property configuration, not listed characteristics is kept at it's current value, e.g. when overriding enumerable property, and not stating new value for enumerable
, the property will stay enumerable.
Currently there's no way with d
to maintain such defaults, we need to be explicit about all property characteristics, otherwise it'll be just set to false. That's a big downside
Possibly it could work that way:
d(value)
- no configuration, keep current behavior { configurable: true, writable: true, enumerable: false, value }
)d('c!w', value)
- Pass only listed configuration properties, and if we want to negate setting, precede it with !
. Therefore in this example it'll turn to { configurable: true, writable: false, value }
I have installed node-gyp globally in order to install scrypt. While installing the node-gyp package, the [email protected] package was installed along with it. Realising that I did not need the node-gyp and scrypt packages, I have tried to remove the [email protected] package, but sudo npm uninstall does not remove it. How can I properly uninstall this packages?
Thank you. J
Is the "lazy" example from the README still supported?
$ node -v
v0.10.29
$ cat package.json | grep '"d":'
"d": "~0.1.1",
$ cat test.js
var d = require('d');
var lazy = require('d/lazy');
var Foo = function () {};
lazy(Foo.prototype, {
items: d(function () { return []; })
});
var foo = new Foo();
foo.items.push(1, 2); // foo.items array created
$ node test.js
foo.items.push(1, 2); // foo.items array created
^
TypeError: Cannot call method 'push' of undefined
at Object.<anonymous> (/Users/michael/Projects/mach/test.js:10:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Hello,
I'd like to formerly ask if you could reconsider the name of your package for something more meaningful. It's hard to know what a single letter package does, and there's another reason as well... Mistyping an npm i
command by forgetting the -
would install your package. Typing npm i d react
(install d
and react
instead of mistyped react -d
). There's also a -
pacakge on npm, so mistyping a space would install both -
and d
packages.
Your lib seems cool, please don't troll other people.
The "main" property makes systemjs happy.
Just had another thing break due to missing d/d
:(
Could you please restore d/d
until you bump major version?
> yo kraken
module.js:340
throw err;
^
Error: Cannot find module 'd/d'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/yo/node_modules/insight/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/event-emitter/lib/core.js:3:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.