Dia antes primera install

This commit is contained in:
2025-12-08 15:20:28 -06:00
commit 1416478c9c
4130 changed files with 886376 additions and 0 deletions

3
node_modules/for-each-property/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
node_modules/
_private/
npm-debug*

3
node_modules/for-each-property/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,3 @@
language: node_js
node_js:
- "6"

149
node_modules/for-each-property/README.md generated vendored Normal file
View File

@@ -0,0 +1,149 @@
# for-each-property
[![Build Status](https://api.travis-ci.org/DiegoZoracKy/for-each-property.svg)](https://travis-ci.org/DiegoZoracKy/for-each-property)
Executes a callback for each property found on a object, with options regarding **enumerability** (enumerable or non-enumerable) and **ownership** (inherited or only own properties). It excludes built-in properties from Object and Function prototypes by default, and this behaviour can also be configured via options.
## Goal
The goal is to provide a way to iterate through object's properties with a clean interface regarding **enumerability** and **ownership**, e.g. `{ enumerability: 'enumerable', inherited: true }`. Also, discarding (or not, is an option) the built-in properties that may be found when looking up on the prototype-chain.
Currently JavaScript has some native methods to handle some cases, but not for all, and not with easy guessing names. Under the hood, the native methods available for some of the cases are being used. For example: `Object.keys` to *enumerable* and not *inherited*, `for..in`to *enumerable* and *inherited*, `Object.getOwnPropertyNames` for own properties, not *inherited*, *enumerable* and *nonenumerable*.
Check [for-each-property-deep](https://github.com/DiegoZoracKy/for-each-property-deep) for a recursive version, which will traverse object's nested properties.
## Usage
```javascript
const forEachProperty = require('for-each-property');
const object = {prop: 1, prop2: '2'};
const callback = (value, key) => console.log(value, key);
const options = {enumerability: 'enumerable', inherited: false};
forEachProperty(object, callback, options);
```
**object**:
Literal object, Object Instance, Class Reference... Any object whose properties can be iterated on.
**callback**:
Function that will receive `(value, key, object)` (object is the one forEachProperty() is being applied to)
**options**:
* **enumerability**:
The options are: `'enumerable'` *(default)*, `'nonenumerable'` or `'all'`
* **inherited**:
The options are: `true` *(default)* or `false`
* **excludeBuiltInPropsOf**:
An array of objects whose prototype properties must be excluded. It defaults to `[Function, Object]`
* **excludeProps**:
An array properties that must be excluded. The default is `['prototype']`
## Example
Example testing all available cases, using an object created from a "parent", with properties enumerables and non-enumerables, inherited and not inherited;
```javascript
const forEachProperty = require('for-each-property');
/////////////////////////////////////////
// OBJECT.CREATE FROM PARENT PROTOTYPE //
/////////////////////////////////////////
const Parent = function() {};
Parent.ParentEnumerableProp = 'ParentEnumerablePropVALUE';
Object.defineProperty(Parent.prototype, 'ParentEnumerablePropt', {
configurable: true,
enumerable: true,
writable: true,
value: 'ParentEnumerableProptVALUE'
});
Object.defineProperty(Parent.prototype, 'ParentNonEnumerableProto', {
configurable: false,
enumerable: false,
writable: false,
value: 'ParentNonEnumerableProtoVALUE'
});
Object.defineProperty(Parent, 'parentNonEnumerableProp', {
configurable: false,
enumerable: false,
writable: false,
value: 'parentNonEnumerablePropVALUE'
});
const objectCreatedFromParentProto = Object.create(Parent, {
ownNonEmurableProp: {
value: 'ownNonEmurablePropVALUE'
},
ownEmurableProp: {
value: 'ownEmurablePropVALUE',
enumerable: true
}
});
objectCreatedFromParentProto.enumerableProp = 'enumerablePropVALUE';
//////////
// MAIN //
//////////
console.log(`========= For each own enumerable property =======`);
forEachProperty(objectCreatedFromParentProto, value => console.log(value), {enumerability: 'enumerable', inherited: false});
console.log(`========= For each own non-enumerable property =======`);
forEachProperty(objectCreatedFromParentProto, value => console.log(value), {enumerability: 'nonenumerable', inherited: false});
console.log(`========= For each own enumerable and non-enumerable property =======`);
forEachProperty(objectCreatedFromParentProto, value => console.log(value), {enumerability: 'all', inherited: false});
console.log(`========= For each enumerable property, including inherited properties =======`);
forEachProperty(objectCreatedFromParentProto, key => console.log(key), {enumerability: 'enumerable', inherited: true});
console.log(`========= For each non-enumerable property, including inherited properties =======`);
forEachProperty(objectCreatedFromParentProto, key => console.log(key), {enumerability: 'nonenumerable', inherited: true});
console.log(`========= For each enumerable and non-enumerable property, including inherited properties =======`);
forEachProperty(objectCreatedFromParentProto, key => console.log(key), {enumerability: 'all', inherited: true});
/////////////////////////
// CONSOLE.LOG RESULTS //
/////////////////////////
// === For each own enumerable property ===
// ownEmurablePropVALUE
// enumerablePropVALUE
// === For each own non-enumerable property ===
// ownNonEmurablePropVALUE
// === For each own enumerable and non-enumerable property ===
// ownNonEmurablePropVALUE
// ownEmurablePropVALUE
// enumerablePropVALUE
// === For each enumerable property, including inherited properties ===
// ownEmurablePropVALUE
// enumerablePropVALUE
// ParentEnumerablePropVALUE
// === For each non-enumerable property, including inherited properties ===
// ownNonEmurablePropVALUE
// parentNonEnumerablePropVALUE
// === For each enumerable and non-enumerable property, including inherited properties ===
// ownNonEmurablePropVALUE
// ownEmurablePropVALUE
// enumerablePropVALUE
// ParentEnumerablePropVALUE
// parentNonEnumerablePropVALUE
```

View File

@@ -0,0 +1,95 @@
'use strict';
const getPrototypeChain = require('get-prototype-chain');
function mountBuiltInPropsToExclude(excludeBuiltInPropsOf, excludeProps) {
return excludeBuiltInPropsOf.reduce((result, o) => result.concat(Object.getOwnPropertyNames(o.prototype)), excludeProps);
}
// All own properties, not inherited, enumerable and non-enumerable. Options to exclude Object and Functions prototypes' built-in properties
function forEachOwnEnumerableAndNonenumerableProperty(o, callback, { excludeBuiltInPropsOf = [Function, Object], excludeProps = ['prototype'] } = {}) {
const builtInPropsToExclude = mountBuiltInPropsToExclude(excludeBuiltInPropsOf, excludeProps);
Object.getOwnPropertyNames(o)
.forEach(prop => !builtInPropsToExclude.includes(prop) && callback(o[prop], prop, o));
}
// All own properties, not inherited, enumerable only
function forEachOwnEnumerableProperty(o, callback) {
Object.keys(o).forEach(prop => callback(o[prop], prop, o));
}
// All own properties, not inherited, non-enumerable only
function forEachOwnNonenumerableProperty(o, callback, { excludeBuiltInPropsOf = [Function, Object], excludeProps = ['prototype'] } = {}) {
const builtInPropsToExclude = mountBuiltInPropsToExclude(excludeBuiltInPropsOf, excludeProps);
Object.getOwnPropertyNames(o)
.forEach(prop => !builtInPropsToExclude.includes(prop) && !o.propertyIsEnumerable(prop) && callback(o[prop], prop, o));
}
// All properties, including inherited (prototype-chain), enumerable and non-enumerable
function forEachEnumerableAndNonenumerableProperty(o, callback, { excludeBuiltInPropsOf = [Function, Object], excludeProps = ['prototype'] } = {}) {
const builtInPropsToExclude = mountBuiltInPropsToExclude(excludeBuiltInPropsOf, excludeProps);
getPrototypeChain(o)
.forEach(proto => {
if (excludeBuiltInPropsOf.map(prop => prop.prototype).includes(proto)) {
return;
}
Object.getOwnPropertyNames(proto)
.forEach(prop => !builtInPropsToExclude.includes(prop) && callback(o[prop], prop, o));
});
}
// All properties, including inherited (prototype-chain), enumerable only, excluding Object and Functions prototypes' built-in properties
function forEachEnumerableProperty(o, callback) {
for (let prop in o) {
callback(o[prop], prop, o);
}
}
// All properties, including inherited (prototype-chain), non-enumerableonly
function forEachNonenumerableProperty(o, callback, { excludeBuiltInPropsOf = [Function, Object], excludeProps = ['prototype'] } = {}) {
const builtInPropsToExclude = mountBuiltInPropsToExclude(excludeBuiltInPropsOf, excludeProps);
getPrototypeChain(o)
.forEach(proto => {
if (excludeBuiltInPropsOf.map(prop => prop.prototype).includes(proto)) {
return;
}
Object.getOwnPropertyNames(proto)
.forEach(prop => {
!builtInPropsToExclude.includes(prop) && !proto.propertyIsEnumerable(prop) && callback(o[prop], prop, o);
});
});
}
function forEachProperty(o, callback, { enumerability = 'enumerable', inherited = false, excludeBuiltInPropsOf = [Function, Object], excludeProps = ['prototype'] } = {}) {
if (!inherited && enumerability === 'enumerable') {
forEachOwnEnumerableProperty(o, callback, { excludeBuiltInPropsOf, excludeProps });
}
if (!inherited && enumerability === 'nonenumerable') {
forEachOwnNonenumerableProperty(o, callback, { excludeBuiltInPropsOf, excludeProps });
}
if (!inherited && enumerability === 'all') {
forEachOwnEnumerableAndNonenumerableProperty(o, callback, { excludeBuiltInPropsOf, excludeProps });
}
if (inherited && enumerability === 'enumerable') {
forEachEnumerableProperty(o, callback, { excludeBuiltInPropsOf, excludeProps });
}
if (inherited && enumerability === 'nonenumerable') {
forEachNonenumerableProperty(o, callback, { excludeBuiltInPropsOf, excludeProps });
}
if (inherited && enumerability === 'all') {
forEachEnumerableAndNonenumerableProperty(o, callback, { excludeBuiltInPropsOf, excludeProps });
}
}
module.exports = forEachProperty;

42
node_modules/for-each-property/package.json generated vendored Normal file
View File

@@ -0,0 +1,42 @@
{
"name": "for-each-property",
"version": "0.0.4",
"description": "Executes a callback for each property found on a object, with options regarding enumerability (enumerable or non-enumerable) and ownership (inherited or only own properties). It excludes built-in properties from Object and Function prototypes by default, and this behaviour can also be configured via options.",
"main": "lib/for-each-property.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "mocha ./test"
},
"keywords": [
"for",
"each",
"prop",
"property",
"object",
"function",
"enumerable",
"non-enumerable",
"nonenumerable",
"inherited",
"proto",
"prototype",
"prototype-chain",
"class",
"static"
],
"author": {
"name": "Diego ZoracKy",
"email": "diego.zoracky@gmail.com",
"url": "https://github.com/DiegoZoracKy/"
},
"license": "MIT",
"dependencies": {
"get-prototype-chain": "^1.0.1"
},
"devDependencies": {
"chai": "^3.5.0",
"mocha": "^3.4.2"
}
}

49
node_modules/for-each-property/test/main.test.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
'use strict';
const assert = require('assert');
const forEachProperty = require('../');
const testDataSet = require('./test.data.js');
testDataSet.forEach(testData => {
describe(testData.name, function() {
describe(`forEachOwnEnumerableProperty :: enumerability: 'enumerable', inherited: false`, function() {
testMethod(forEachProperty, testData.ref, testData.forEachOwnEnumerableProperty, { enumerability: 'enumerable', inherited: false });
});
describe(`forEachOwnNonenumerableProperty :: enumerability: 'nonenumerable', inherited: false`, function() {
testMethod(forEachProperty, testData.ref, testData.forEachOwnNonenumerableProperty, { enumerability: 'nonenumerable', inherited: false });
});
describe(`forEachOwnEnumerableAndNonenumerableProperty :: enumerability: 'all', inherited: false`, function() {
testMethod(forEachProperty, testData.ref, testData.forEachOwnEnumerableAndNonenumerableProperty, { enumerability: 'all', inherited: false });
});
describe(`forEachEnumerableProperty :: enumerability: 'enumerable', inherited: true`, function() {
testMethod(forEachProperty, testData.ref, testData.forEachEnumerableProperty, { enumerability: 'enumerable', inherited: true });
});
describe(`forEachNonenumerableProperty :: enumerability: 'nonenumerable', inherited: true`, function() {
testMethod(forEachProperty, testData.ref, testData.forEachNonenumerableProperty, { enumerability: 'nonenumerable', inherited: true });
});
describe(`forEachEnumerableAndNonenumerableProperty :: enumerability: 'all', inherited: true`, function() {
testMethod(forEachProperty, testData.ref, testData.forEachEnumerableAndNonenumerableProperty, { enumerability: 'all', inherited: true });
});
});
});
function testMethod(methodToTest, ref, propsExpected, options) {
const propsFound = [];
it(`must find the same number of props expected`, function() {
methodToTest(ref, (value, key, o) => {
propsFound.push(key);
}, options);
assert.equal(propsFound.length, propsExpected.length);
});
it(`must find every prop expected`, function() {
assert(propsFound.every(prop => propsExpected.includes(prop)));
});
}

247
node_modules/for-each-property/test/test.data.js generated vendored Normal file
View File

@@ -0,0 +1,247 @@
//////////////
// Function //
//////////////
function functionWithProperties() {}
// Function Inner Property
functionWithProperties.functionWithPropertiesEnumerablePropEnumerable = 'functionWithPropertiesEnumerablePropEnumerableVALUE';
Object.defineProperty(functionWithProperties, 'functionWithPropertiesEnumerablePropNonEnumerable', {
configurable: true,
enumerable: false,
writable: true,
value: 'functionWithPropertiesEnumerablePropNonEnumerableVALUE'
});
Object.defineProperty(functionWithProperties.prototype, 'protoEnumerableProp', {
configurable: true,
enumerable: true,
writable: true,
value: 'protoEnumerablePropVALUE'
});
Object.defineProperty(functionWithProperties.prototype, 'protoNonEnumerableProp', {
configurable: true,
enumerable: false,
writable: true,
value: 'nonEnumerablePropVALUE'
});
///////////////////////////////////
// Object Instance from Function //
// Object.defineProperty //
///////////////////////////////////
const instanceFromFunctionWithProperties = new functionWithProperties();
Object.defineProperty(instanceFromFunctionWithProperties, 'propEnumerable', {
configurable: true,
enumerable: true,
writable: true,
value: 'propEnumerableVALUE'
});
Object.defineProperty(instanceFromFunctionWithProperties, 'propNonEnumerable', {
configurable: true,
enumerable: false,
writable: true,
value: 'propNonEnumerableVALUE'
});
////////////////////
// Object Literal //
////////////////////
const fnTest = x => console.log('fnTest!');
fnTest.innerFn = x => console.log('fnTest.innerFn!');
const objectLiteral = {
a: {
b: {
c: x => x
},
d: 'e',
f: {
g: 'h'
}
},
fn: fnTest,
z: {
k: {},
zk: 'ZK',
N: 1984,
de: { ep: 10 },
kz: {
zz: {
kk: function ha() {}
},
k: 'K',
fnR: fnTest
}
}
};
///////////
// CLASS //
///////////
class classRef3 {
constructor() {
this.z = 'classRef3';
}
static classRef3Static() {
console.log('classRef3Static');
}
fffn() {
console.log('classRef3Static fffn');
}
ffn() {
console.log('classRef3Static ffn');
}
}
class classRef2 extends classRef3 {
constructor() {
super();
this.zz = 'classRef2';
this.superFn = {
superInnerFn: x => console.log(`superFn!`)
};
this.superFn.superInnerFn.fnWithProp = x => console.log(`fnWithProp!`);
}
static classRef2Static() {
console.log('classRef2Static');
}
ffn() {
console.log('classRef2Static ffn');
}
}
class classRef extends classRef2 {
constructor() {
super();
this.z = 'classRef';
this.instanceFn = x => console.log(`instanceFn!`);
}
static classRefStatic() {
console.log('classRefStatic');
}
fn() {
console.log('classRefStatic fn');
}
}
////////////////////////////////
// OBJECT INSTANCE FROM CLASS //
////////////////////////////////
const instanceFromClassRef = new classRef();
Object.defineProperty(instanceFromClassRef, 'instanceFnNonEnumerable', {
value: 'instanceFnNonEnumerableVALUE'
});
/////////////////////////////////////////
// OBJECT.CREATE FROM PARENT PROTOTYPE //
/////////////////////////////////////////
const Parent = function() {};
Parent.ParentEnumerableProp = 'ParentEnumerablePropVALUE';
Object.defineProperty(Parent.prototype, 'ParentEnumerablePropt', {
configurable: true,
enumerable: true,
writable: true,
value: 'ParentEnumerableProptVALUE'
});
Object.defineProperty(Parent.prototype, 'ParentNonEnumerableProto', {
configurable: false,
enumerable: false,
writable: false,
value: 'ParentNonEnumerableProtoVALUE'
});
Object.defineProperty(Parent, 'parentNonEnumerableProp', {
configurable: false,
enumerable: false,
writable: false,
value: 'parentNonEnumerablePropVALUE'
});
const objectCreatedWithParentProto = Object.create(Parent, {
ownNonEmurableProp: {
value: 'ownNonEmurablePropVALUE'
},
ownEmurableProp: {
value: 'ownEmurablePropVALUE',
enumerable: true
}
});
objectCreatedWithParentProto.enumerableProp = 'enumerablePropVALUE';
module.exports = [{
name: 'functionWithProperties',
ref: functionWithProperties,
forEachOwnEnumerableProperty: ['functionWithPropertiesEnumerablePropEnumerable'],
forEachOwnNonenumerableProperty: ['functionWithPropertiesEnumerablePropNonEnumerable'],
forEachOwnEnumerableAndNonenumerableProperty: ['functionWithPropertiesEnumerablePropEnumerable', 'functionWithPropertiesEnumerablePropNonEnumerable'],
forEachEnumerableProperty: ['functionWithPropertiesEnumerablePropEnumerable'],
forEachNonenumerableProperty: ['functionWithPropertiesEnumerablePropNonEnumerable'],
forEachEnumerableAndNonenumerableProperty: ['functionWithPropertiesEnumerablePropEnumerable', 'functionWithPropertiesEnumerablePropNonEnumerable']
}, {
name: 'instanceFromFunctionWithProperties',
ref: instanceFromFunctionWithProperties,
forEachOwnEnumerableProperty: ['propEnumerable'],
forEachOwnNonenumerableProperty: ['propNonEnumerable'],
forEachOwnEnumerableAndNonenumerableProperty: ['propEnumerable', 'propNonEnumerable'],
forEachEnumerableProperty: ['propEnumerable', 'protoEnumerableProp'],
forEachNonenumerableProperty: ['propNonEnumerable', 'protoNonEnumerableProp'],
forEachEnumerableAndNonenumerableProperty: ['propEnumerable', 'propNonEnumerable', 'protoEnumerableProp', 'protoNonEnumerableProp']
}, {
name: 'objectLiteral',
ref: objectLiteral,
forEachOwnEnumerableProperty: ['a', 'fn', 'z'],
forEachOwnNonenumerableProperty: [],
forEachOwnEnumerableAndNonenumerableProperty: ['a', 'fn', 'z'],
forEachEnumerableProperty: ['a', 'fn', 'z'],
forEachNonenumerableProperty: [],
forEachEnumerableAndNonenumerableProperty: ['a', 'fn', 'z']
}, {
name: 'classRef',
ref: classRef,
forEachOwnEnumerableProperty: [],
forEachOwnNonenumerableProperty: ['classRefStatic'],
forEachOwnEnumerableAndNonenumerableProperty: ['classRefStatic'],
forEachEnumerableProperty: [],
forEachNonenumerableProperty: ['classRefStatic', 'classRef2Static', 'classRef3Static'],
forEachEnumerableAndNonenumerableProperty: ['classRefStatic', 'classRef2Static', 'classRef3Static']
}, {
name: 'instanceFromClassRef',
ref: instanceFromClassRef,
forEachOwnEnumerableProperty: ['z', 'zz', 'superFn', 'instanceFn'],
forEachOwnNonenumerableProperty: ['instanceFnNonEnumerable'],
forEachOwnEnumerableAndNonenumerableProperty: ['z', 'zz', 'superFn', 'instanceFn', 'instanceFnNonEnumerable'],
forEachEnumerableProperty: ['z', 'zz', 'superFn', 'instanceFn'],
forEachNonenumerableProperty: ['instanceFnNonEnumerable', 'fn', 'ffn', 'fffn', 'ffn'],
forEachEnumerableAndNonenumerableProperty: ['z', 'zz', 'superFn', 'instanceFn', 'instanceFnNonEnumerable', 'fn', 'ffn', 'fffn', 'ffn']
}, {
name: 'objectCreatedWithParentProto',
ref: objectCreatedWithParentProto,
forEachOwnEnumerableProperty: ['ownEmurableProp', 'enumerableProp'],
forEachOwnNonenumerableProperty: ['ownNonEmurableProp'],
forEachOwnEnumerableAndNonenumerableProperty: ['ownEmurableProp', 'enumerableProp', 'ownNonEmurableProp'],
forEachEnumerableProperty: ['ownEmurableProp', 'enumerableProp', 'ParentEnumerableProp'],
forEachNonenumerableProperty: ['ownNonEmurableProp', 'parentNonEnumerableProp'],
forEachEnumerableAndNonenumerableProperty: ['ownNonEmurableProp', 'ownEmurableProp', 'enumerableProp', 'ParentEnumerableProp', 'parentNonEnumerableProp']
}];