Socket
Socket
Sign inDemoInstall

node-containerpattern

Package Overview
Dependencies
0
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.1 to 1.6.0

20

lib/index.d.ts

@@ -7,2 +7,20 @@ /// <reference types="node" />

interface iDocumentation {
"fullkey": string;
"type": tType;
"documentation"?: string;
"limits"?: Array<any>;
"min"?: number;
"max"?: number;
"regex"?: string;
}
interface iBasicDocumentation extends iDocumentation {
"value": string | number;
}
interface iComplexDocumentation extends iDocumentation {
"content": { [ key: string ]: iBasicDocumentation | iComplexDocumentation } // Array are decomposed by numeric keys, transformed into string
}
class Container extends Map {

@@ -37,3 +55,3 @@

public document(key: string, value: string): this; // attach a documentation on the data. only visible if "set" method is applied with this key
public documentation(): object; // generate a documentation for all the stored data
public documentation(): { [ key: string ]: iBasicDocumentation | iComplexDocumentation }; // generate a documentation for all the stored data
// public get(key: string): any; // the value in association with this key (may be recursive)

@@ -40,0 +58,0 @@ // public has(key: string): boolean; // check if a key is used (may be recursive)

50

lib/main.js

@@ -223,36 +223,42 @@ /*

let min = null;
const documentation = {
"fullkey": fullKey,
type
};
if (this.documentations[fullKey]) {
documentation.documentation = this.documentations[fullKey];
}
if (isDefined(this.mins[fullKey])) {
min = this.mins[fullKey];
documentation.min = this.mins[fullKey];
}
else if ("array" === type) {
min = 0;
documentation.min = 0;
}
let regex = null;
if (isDefined(this.regexs[fullKey])) {
regex = stringifyRegex(this.regexs[fullKey]);
if (isDefined(this.maxs[fullKey])) {
documentation.max = this.maxs[fullKey];
}
result[key] = {
"documentation": this.documentations[fullKey] ? this.documentations[fullKey] : "",
"fullkey": fullKey,
min,
"max": isDefined(this.maxs[fullKey]) ? this.maxs[fullKey] : null,
"limits": isArray(this.limits[fullKey]) ? this.limits[fullKey] : null,
regex,
type
};
if (isArray(this.limits[fullKey])) {
documentation.limits = this.limits[fullKey];
}
if ("array" === result[key].type) {
result[key].content = isEmptyArray(value) ? {} : this._extractDocumentation(fullKey, value);
if (isDefined(this.regexs[fullKey])) {
documentation.regex = stringifyRegex(this.regexs[fullKey]);
}
else if ("object" === result[key].type) {
result[key].content = isEmptyPlainObject(value) ? {} : this._extractDocumentation(fullKey, value);
}
else if ("function" !== result[key].type) {
result[key].value = value;
if ("array" === type) {
documentation.content = isEmptyArray(value) ? {} : this._extractDocumentation(fullKey, value);
}
else if ("object" === type) {
documentation.content = isEmptyPlainObject(value) ? {} : this._extractDocumentation(fullKey, value);
}
else if ("function" !== type) {
documentation.value = value;
}
result[key] = documentation;
});

@@ -259,0 +265,0 @@

{
"name": "node-containerpattern",
"version": "1.5.1",
"version": "1.6.0",
"description": "A 'Container pattern' object for a clean global use of data.",

@@ -5,0 +5,0 @@ "main": "lib/main.js",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc