Initial commit, 90% there

This commit is contained in:
mdares
2025-12-02 16:27:21 +00:00
commit 755028af7e
7353 changed files with 1759505 additions and 0 deletions

4
.node-red/node_modules/inspect-property/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,4 @@
node_modules/
_private/
npm-debug.log
.jshintrc

4
.node-red/node_modules/inspect-property/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- 6
- 8

171
.node-red/node_modules/inspect-property/README.md generated vendored Normal file
View File

@@ -0,0 +1,171 @@
# inspect-property
[![Build Status](https://api.travis-ci.org/DiegoZoracKy/inspect-property.svg)](https://travis-ci.org/DiegoZoracKy/inspect-property) [![npm](https://img.shields.io/npm/v/inspect-property.svg)]() [![npm](https://img.shields.io/npm/l/inspect-property.svg)]()
Inspects a Property and returns useful informations about it (e.g. nested properties, function inspection, property descriptor, value, type, constructor)
## Installation
```bash
npm install inspect-property
```
## Usage
```javascript
inspectProperty(o, propertyName, { delimiter = '.', inspectFunction = true, inspectProperties = true, enumerability, inherited} = {} );
```
**o**:
Object || Property || Value to be inspected.
**propertyName**:
When passing as `inspectProperty(parentObject, 'childPropertyName')`, `propertyDescriptor` will be returned. Note that `childPropertyName` must be a `string`.
**delimiter**
What will be used as a delimiter for the nested properties at `properties` keys. Default is `','` e.g. `'a.b.c'`
**inspectFunction**
If functions should be inspected. See [inspect-function](https://github.com/DiegoZoracKy/inspect-function) for details about the function inspection.
**inspectProperties**
When set to false, `properties` will be a simple `{key: value}` object, without any inspection. The default value is `true`, returning `{key: inspectProperty(value)}`.
**path**
An array representing the current property path. e.g. from the above example it will be `[ 'a', 'b', 'c' ]` for the `'c'` property
**parent**
The parent object of the current property. e.g. from the above example it will be the object `{ c: 'cValue' }` for the `'c'` property
**enumerability**:
When inspecting nested properties, defines how it should look up regarding `enumerability`.
The options are:
* `'enumerable'` *(default)*
* `'nonenumerable'`
* `'all'`
**inherited**:
Determines if it should look up on the prototype chain when inspecting nested properties.
The options are:
* `true` *(default)*
* `false`
## Example
```javascript
const inspectProperty = require('../');
const data = {
a: {
b: {
c: (z = 'DefaultX', k) => z+k
},
d: 3,
f: {
g: 'h'
}
}
};
const result = inspectProperty(data);
////////////
// RESULT //
////////////
// Below is a JSON.stringify(result), so functions references are ommitted
{
"value": {
"a": {
"b": {},
"d": 3,
"f": {
"g": "h"
}
}
},
"type": "object",
"constructor": {
"name": "Object"
},
"properties": {
"a": {
"value": {
"b": {},
"d": 3,
"f": {
"g": "h"
}
},
"type": "object",
"constructor": {
"name": "Object"
},
"properties": {
"b": {},
"d": 3,
"f": {
"g": "h"
},
"f.g": "h"
}
},
"a.b": {
"value": {},
"type": "object",
"constructor": {
"name": "Object"
},
"properties": {}
},
"a.b.c": {
"type": "function",
"constructor": {
"name": "Function"
},
"functionInspection": {
"name": "c",
"signature": "c(z = 'DefaultX', k);",
"parameters": [
{
"parameter": "z",
"defaultValue": "DefaultX",
"declaration": "z = 'DefaultX'"
},
{
"parameter": "k",
"declaration": "k"
}
],
"parametersNames": [
"z",
"k"
]
},
"properties": {}
},
"a.d": {
"value": 3,
"type": "number",
"constructor": {
"name": "Number"
}
},
"a.f": {
"value": {
"g": "h"
},
"type": "object",
"constructor": {
"name": "Object"
},
"properties": {
"g": "h"
}
},
"a.f.g": {
"value": "h",
"type": "string",
"constructor": {
"name": "String"
}
}
}
}

View File

@@ -0,0 +1,39 @@
'use strict';
const _inspectFunction = require('inspect-function');
const forEachProperty = require('for-each-property');
const forEachPropertyDeep = require('for-each-property-deep');
function inspectProperty(o, propertyName, { delimiter = '.', inspectFunction = true, inspectProperties = true, enumerability, inherited } = {}) {
const property = o && propertyName ? o[propertyName] : o;
const propertyInspection = {
value: property,
type: typeof(property),
constructor: {
name: property && property.constructor && property.constructor.name,
ref: property && property.constructor
}
};
if (o && propertyName) {
propertyInspection.propertyDescriptor = Object.getOwnPropertyDescriptor(o, propertyName);
}
if (propertyInspection.type === 'function' && inspectFunction) {
propertyInspection.functionInspection = _inspectFunction(property);
}
if (propertyInspection.type === 'function' || propertyInspection.type === 'object') {
propertyInspection.properties = forEachPropertyDeep(property, (value, key, path, parent, state) => {
state[path.join(delimiter)] = value;
}, { enumerability, inherited });
forEachProperty(propertyInspection.properties, (value, key) => {
propertyInspection.properties[key] = value === undefined || value === null || !inspectProperties ? value : inspectProperty(value, null, { inspectFunction, inspectProperties: false });
});
}
return propertyInspection;
}
module.exports = inspectProperty;

32
.node-red/node_modules/inspect-property/package.json generated vendored Normal file
View File

@@ -0,0 +1,32 @@
{
"name": "inspect-property",
"version": "0.0.6",
"description": "Inspects a Property and returns useful informations about it (e.g. nested properties, function inspection, property descriptor, value, type, constructor)",
"main": "lib/inspect-property.js",
"author": {
"name": "Diego ZoracKy",
"email": "diego.zoracky@gmail.com",
"url": "https://github.com/DiegoZoracKy/"
},
"keywords": [
"inspect",
"property",
"api",
"methods",
"properties"
],
"scripts": {
"test": "mocha ./test/main.test.js",
"test:all": "mocha ./test -b"
},
"license": "MIT",
"devDependencies": {
"chai": "^3.5.0",
"mocha": "^3.3.0"
},
"dependencies": {
"for-each-property": "0.0.4",
"for-each-property-deep": "0.0.3",
"inspect-function": "^0.3.1"
}
}

View File

@@ -0,0 +1,60 @@
'use strict';
function functionObject() {
this.inner = 'property';
}
// Function Inner Property
functionObject.functionObjectEnumerablePropEnumerable = 'functionObjectEnumerablePropEnumerableVALUE';
Object.defineProperty(functionObject, 'functionObjectEnumerablePropNonEnumerable', {
configurable: true,
enumerable: false,
writable: true,
value: 'functionObjectEnumerablePropNonEnumerableVALUE'
});
Object.defineProperty(functionObject.prototype, 'protoEnumerableProp', {
configurable: true,
enumerable: true,
writable: true,
value: 'protoEnumerablePropVALUE'
});
Object.defineProperty(functionObject.prototype, 'protoNonEnumerableProp', {
configurable: true,
enumerable: false,
writable: true,
value: 'nonEnumerablePropVALUE'
});
const instanceFromFunctionObject = new functionObject();
Object.defineProperty(instanceFromFunctionObject, 'propEnumerable', {
configurable: true,
enumerable: true,
writable: true,
value: 'propEnumerableVALUE'
});
Object.defineProperty(instanceFromFunctionObject, 'propNonEnumerable', {
configurable: true,
enumerable: false,
writable: true,
value: 'propNonEnumerableVALUE'
});
instanceFromFunctionObject.a = {
b: {
c: x => x
},
d: 3,
f: {
g: 'h'
}
};
module.exports = {
instanceFromFunctionObject,
functionObject
}

View File

@@ -0,0 +1,17 @@
'use strict';
const inspectProperty = require('../');
const testSpecs = require('./specs/main-specs.js');
testSpecs.forEach(spec => {
describe(spec.description, function(){
const method = spec.method ? inspectProperty[spec.method] : inspectProperty;
const input = spec.input;
const output = spec.fn(method, input);
spec.tests.forEach(test => {
it(test.description, function(){
return test.fn(output, input);
});
});
});
});

View File

@@ -0,0 +1,120 @@
'use strict';
const assert = require('assert');
const { functionObject, instanceFromFunctionObject } = require('../data/main-data.js');
module.exports = [
{
description: `Test functionObject {enumerability: 'enumerable'}`,
input: functionObject,
fn: (method, input) => method(input, null, { enumerability: 'enumerable' }),
tests: [{
description: "Check Type",
fn: (output, input) => assert(output.type, 'function'),
}, {
description: "Check Constructor Name",
fn: (output, input) => assert(output.constructor.name, 'Function'),
}, {
description: "Check functionInspection name",
fn: (output, input) => assert(output.functionInspection.name, 'functionObject'),
}, {
description: "Check Properties",
fn: (output, input) => {
const mustInclude = ['functionObjectEnumerablePropEnumerable'];
return assert(Object.keys(output.properties).every(key => mustInclude.includes(key)));
}
}, {
description: "Property Type",
fn: (output, input) => {
return assert(output.properties.functionObjectEnumerablePropEnumerable.type, 'string');
}
}]
},
{
description: `Test instanceFromFunctionObject {enumerability: 'enumerable'}`,
input: instanceFromFunctionObject,
fn: (method, input) => method(input, null, { enumerability: 'enumerable' }),
tests: [{
description: "Check Type Name",
fn: (output, input) => assert(output.type, 'object'),
}, {
description: "Check Constructor Name",
fn: (output, input) => assert(output.constructor.name, 'functionObject'),
}, {
description: "Check Properties",
fn: (output, input) => {
const mustInclude = [
'inner',
'propEnumerable',
'propNonEnumerable',
'a',
'a.b',
'a.b.c',
'a.d',
'a.f',
'a.f.g',
'protoEnumerableProp',
'protoNonEnumerableProp'
];
return assert(Object.keys(output.properties).every(key => mustInclude.includes(key)));
}
}]
},
{
description: `Test instanceFromFunctionObject {enumerability: 'all', inherited: true}`,
input: instanceFromFunctionObject,
fn: (method, input) => method(input, null, { enumerability: 'all', inherited: true }),
tests: [{
description: "Check Type Name",
fn: (output, input) => assert(output.type, 'object'),
}, {
description: "Check Constructor Name",
fn: (output, input) => assert(output.constructor.name, 'functionObject'),
}, {
description: "Check Properties",
fn: (output, input) => {
const mustInclude = [
'inner',
'propEnumerable',
'propNonEnumerable',
'a',
'a.b',
'a.b.c',
'a.d',
'a.f',
'a.f.g',
'protoEnumerableProp',
'protoNonEnumerableProp'
];
return assert(Object.keys(output.properties).every(key => mustInclude.includes(key)));
}
}]
},
{
description: `Test instanceFromFunctionObject {delimiter: '|'}`,
input: instanceFromFunctionObject,
fn: (method, input) => method(input, null, { delimiter: '|' }),
tests: [{
description: "Check Type Name",
fn: (output, input) => assert(output.type, 'object'),
}, {
description: "Check Constructor Name",
fn: (output, input) => assert(output.constructor.name, 'functionObject'),
}, {
description: "Check Properties",
fn: (output, input) => {
const mustInclude = [
'inner',
'propEnumerable',
'a',
'a|b',
'a|b|c',
'a|d',
'a|f',
'a|f|g'
];
return assert(Object.keys(output.properties).every(key => mustInclude.includes(key)));
}
}]
}
];