Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pd

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pd - npm Package Compare versions

Comparing version 0.3.1 to 0.3.3

2

package.json
{
"name": "pd",
"version": "0.3.1",
"version": "0.3.3",
"description": "Manage propertyDescriptors, an OO utility",

@@ -5,0 +5,0 @@ "keywords": ["oo", "oop", "propertydescriptor", "arch", "utility"],

@@ -121,2 +121,3 @@ # pd <a name="_pd" href="#_pd"><small><sup>link</sup></small></a>

- Object.prototype.beget (same as pd.beget)
- Object.prototype.make (same as pd.make)
- Object.make (same as pd.make)

@@ -129,7 +130,28 @@ - Object.Name (same as pd.Name)

An example of `.make` which only extends it with one argument
Proto.make({ /* subclass properties */ })
### pd.Name <a name="pd.Name" href="#pdName"><small><sup>link</sup</small></a>
pd.Name does shit, read the source \o/. I mean docs soon.
pd.Name constructs a Name function. This name function when passed your object will
return a privates object. This privates object cannot be accessed in any other
way then calling Name.
Example:
var Klass = (function () {
var privates = pd.Name();
return {
constructor: function (secret) {
privates(this).secret = secret;
},
getSecret: function () {
return privates(this).secret;
}
};
}());
[1]: http://raynos.github.com/pd/docs/pd.html

@@ -136,0 +158,0 @@ [2]: http://raynos.github.com/vows-fluent/docs/vows-fluent.html

@@ -28,2 +28,4 @@ !(function (exports) {

function extendNatives(prototypes) {
prototypes === true && (prototypes = ["make", "beget", "extend"]);
if (!Object.getOwnPropertyDescriptors) {

@@ -53,3 +55,3 @@ Object.defineProperty(Object, "getOwnPropertyDescriptors", {

}
if (!Object.prototype["beget"] && prototypes) {
if (!Object.prototype.beget && prototypes.indexOf("beget") !== -1) {
Object.defineProperty(Object.prototype, "beget", {

@@ -64,2 +66,19 @@ value: function _beget() {

}
if (!Object.prototype.make && prototypes.indexOf("make") !== -1) {
Object.defineProperty(Object.prototype, "make", {
value: function _make() {
var args = [].slice.call(arguments);
return make.apply(null, [this].concat(args));
},
configurable: true
});
}
if (!Object.prototype.extend && prototypes.indexOf("extend") !== -1) {
Object.defineProperty(Object.prototype, "extend", {
value: function _extend() {
var args = [].slice.call(arguments);
return extend.apply(null, [this].concat(args));
}
});
}
if (!Object.Name) {

@@ -131,2 +150,11 @@ Object.defineProperty(Object, "Name", {

/*
defines a namespace object. This hides a "privates" object on object
under the "key" namespace
@param Object object - object to hide a privates object on
@param Object namespace - key to hide it under
@return Object privates
*/
function defineNamespace(object, namespace) {

@@ -149,2 +177,8 @@ var privates = Object.create(object),

/*
Constructs a Name function, when given an object it will return a
privates object.
@return Function name
*/
function Name() {

@@ -151,0 +185,0 @@ var namespace = {};

@@ -61,3 +61,13 @@ var pd = require("../src/pd.js").extendNatives(true),

};
pd.extend(o1,o2,o3);
var o4 = {};
pd.extend(o4, o1,o2,o3);
assert.deepEqual(o4, {
things: "foo",
otherThings: "bar",
moreThings: "baz",
overwrite: "good value"
});
o1.extend(o2, o3);
assert.deepEqual(o1, {

@@ -101,2 +111,12 @@ things: "foo",

assert(o.hasOwnProperty("three"));
var o = Proto.make({
"one": "two",
"three": Proto
});
assert(Proto.isPrototypeOf(o));
assert(o.hasOwnProperty("one"));
assert(o.one === "two");
assert(o.three === Proto);
assert(o.hasOwnProperty("three"));
}

@@ -103,0 +123,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc