@documentdb-js/schema-analyzer 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +50 -0
- package/dist/BSONTypes.d.ts +50 -0
- package/dist/BSONTypes.d.ts.map +1 -0
- package/dist/BSONTypes.js +196 -0
- package/dist/BSONTypes.js.map +1 -0
- package/dist/JSONSchema.d.ts +75 -0
- package/dist/JSONSchema.d.ts.map +1 -0
- package/dist/JSONSchema.js +7 -0
- package/dist/JSONSchema.js.map +1 -0
- package/dist/SchemaAnalyzer.d.ts +71 -0
- package/dist/SchemaAnalyzer.d.ts.map +1 -0
- package/dist/SchemaAnalyzer.js +511 -0
- package/dist/SchemaAnalyzer.js.map +1 -0
- package/dist/ValueFormatters.d.ts +21 -0
- package/dist/ValueFormatters.d.ts.map +1 -0
- package/dist/ValueFormatters.js +85 -0
- package/dist/ValueFormatters.js.map +1 -0
- package/dist/getKnownFields.d.ts +41 -0
- package/dist/getKnownFields.d.ts.map +1 -0
- package/dist/getKnownFields.js +180 -0
- package/dist/getKnownFields.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type JSONSchema } from './JSONSchema';
|
|
2
|
+
export interface FieldEntry {
|
|
3
|
+
/** Dot-notated path (e.g., "user.profile.name") */
|
|
4
|
+
path: string;
|
|
5
|
+
/** JSON type of the dominant type entry ("string", "number", "object", "array", etc.) */
|
|
6
|
+
type: string;
|
|
7
|
+
/** Dominant BSON type from x-bsonType on the most common type entry ("date", "objectid", "int32", etc.) */
|
|
8
|
+
bsonType: string;
|
|
9
|
+
/** All observed BSON types for this field (for polymorphic fields) */
|
|
10
|
+
bsonTypes?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* True if this field was not present in every inspected document
|
|
13
|
+
* (x-occurrence < parent x-documentsInspected).
|
|
14
|
+
*
|
|
15
|
+
* This is a statistical observation, not a schema constraint — in the MongoDB API / DocumentDB API,
|
|
16
|
+
* all fields are implicitly optional.
|
|
17
|
+
*/
|
|
18
|
+
isSparse?: boolean;
|
|
19
|
+
/** If the field is an array, the dominant element BSON type */
|
|
20
|
+
arrayItemBsonType?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* This function traverses our JSON Schema object and collects all leaf property paths
|
|
24
|
+
* along with their most common data types.
|
|
25
|
+
*
|
|
26
|
+
* This information is needed for auto-completion support
|
|
27
|
+
*
|
|
28
|
+
* The approach is as follows:
|
|
29
|
+
* - Initialize a queue with the root properties of the schema to perform a breadth-first traversal.
|
|
30
|
+
* - While the queue is not empty:
|
|
31
|
+
* - Dequeue the next item, which includes the current schema node and its path.
|
|
32
|
+
* - Determine the most common type for the current node by looking at the 'x-typeOccurrence' field.
|
|
33
|
+
* - If the most common type is an object with properties:
|
|
34
|
+
* - Enqueue its child properties with their updated paths into the queue for further traversal.
|
|
35
|
+
* - Else if the most common type is a leaf type (e.g., string, number, boolean):
|
|
36
|
+
* - Add the current path and type to the result array as it represents a leaf property.
|
|
37
|
+
* - Continue this process until all nodes have been processed.
|
|
38
|
+
* - Return the result array containing objects with 'path' and 'type' for each leaf property.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getKnownFields(schema: JSONSchema): FieldEntry[];
|
|
41
|
+
//# sourceMappingURL=getKnownFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKnownFields.d.ts","sourceRoot":"","sources":["../src/getKnownFields.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,UAAU;IACvB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;IACb,2GAA2G;IAC3G,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+DAA+D;IAC/D,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,CAuG/D"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.getKnownFields = getKnownFields;
|
|
11
|
+
const denque_1 = __importDefault(require("denque"));
|
|
12
|
+
/**
|
|
13
|
+
* This function traverses our JSON Schema object and collects all leaf property paths
|
|
14
|
+
* along with their most common data types.
|
|
15
|
+
*
|
|
16
|
+
* This information is needed for auto-completion support
|
|
17
|
+
*
|
|
18
|
+
* The approach is as follows:
|
|
19
|
+
* - Initialize a queue with the root properties of the schema to perform a breadth-first traversal.
|
|
20
|
+
* - While the queue is not empty:
|
|
21
|
+
* - Dequeue the next item, which includes the current schema node and its path.
|
|
22
|
+
* - Determine the most common type for the current node by looking at the 'x-typeOccurrence' field.
|
|
23
|
+
* - If the most common type is an object with properties:
|
|
24
|
+
* - Enqueue its child properties with their updated paths into the queue for further traversal.
|
|
25
|
+
* - Else if the most common type is a leaf type (e.g., string, number, boolean):
|
|
26
|
+
* - Add the current path and type to the result array as it represents a leaf property.
|
|
27
|
+
* - Continue this process until all nodes have been processed.
|
|
28
|
+
* - Return the result array containing objects with 'path' and 'type' for each leaf property.
|
|
29
|
+
*/
|
|
30
|
+
function getKnownFields(schema) {
|
|
31
|
+
const result = [];
|
|
32
|
+
const rootDocumentsInspected = schema['x-documentsInspected'] ?? 0;
|
|
33
|
+
const queue = new denque_1.default();
|
|
34
|
+
// Initialize the queue with root properties
|
|
35
|
+
//
|
|
36
|
+
// Note: JSON Schema allows boolean values as schema references (true = accept all,
|
|
37
|
+
// false = reject all), but our SchemaAnalyzer never produces boolean refs — it always
|
|
38
|
+
// emits full schema objects. The cast to JSONSchema below is therefore safe for our
|
|
39
|
+
// use case. If this function were ever reused with externally-sourced schemas, a
|
|
40
|
+
// `typeof propSchema === 'boolean'` guard should be added here and in the nested
|
|
41
|
+
// property loop below.
|
|
42
|
+
if (schema.properties) {
|
|
43
|
+
for (const propName of Object.keys(schema.properties)) {
|
|
44
|
+
const propSchema = schema.properties[propName];
|
|
45
|
+
queue.push({
|
|
46
|
+
path: propName,
|
|
47
|
+
schemaNode: propSchema,
|
|
48
|
+
parentDocumentsInspected: rootDocumentsInspected,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
while (queue.length > 0) {
|
|
53
|
+
const item = queue.shift();
|
|
54
|
+
if (!item)
|
|
55
|
+
continue;
|
|
56
|
+
const { path, schemaNode, parentDocumentsInspected } = item;
|
|
57
|
+
const mostCommonTypeEntry = getMostCommonTypeEntry(schemaNode);
|
|
58
|
+
if (mostCommonTypeEntry) {
|
|
59
|
+
if (mostCommonTypeEntry.type === 'object' && mostCommonTypeEntry.properties) {
|
|
60
|
+
// Not a leaf node, enqueue its properties
|
|
61
|
+
const objectDocumentsInspected = mostCommonTypeEntry['x-documentsInspected'] ?? 0;
|
|
62
|
+
for (const childName of Object.keys(mostCommonTypeEntry.properties)) {
|
|
63
|
+
const childSchema = mostCommonTypeEntry.properties[childName];
|
|
64
|
+
// TODO: Dot-delimited path concatenation is ambiguous when a field name
|
|
65
|
+
// itself contains a literal dot. For example, a root-level field named
|
|
66
|
+
// "a.b" produces path "a.b", indistinguishable from a nested field
|
|
67
|
+
// { a: { b: ... } }. Fields with literal dots in their names were
|
|
68
|
+
// prohibited before MongoDB API 3.6 and remain rare in practice.
|
|
69
|
+
//
|
|
70
|
+
// Future improvement: change `path` from `string` to `string[]`
|
|
71
|
+
// (segment array) to preserve the distinction between nesting and
|
|
72
|
+
// literal dots, pushing escaping/formatting decisions to consumers
|
|
73
|
+
// (TS definitions, completion items, aggregation references, etc.).
|
|
74
|
+
queue.push({
|
|
75
|
+
path: `${path}.${childName}`,
|
|
76
|
+
schemaNode: childSchema,
|
|
77
|
+
parentDocumentsInspected: objectDocumentsInspected,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Leaf node, build the FieldEntry
|
|
83
|
+
const bsonType = mostCommonTypeEntry['x-bsonType'] ?? mostCommonTypeEntry.type;
|
|
84
|
+
const entry = {
|
|
85
|
+
path,
|
|
86
|
+
type: mostCommonTypeEntry.type,
|
|
87
|
+
bsonType,
|
|
88
|
+
};
|
|
89
|
+
// bsonTypes: collect all distinct x-bsonType values from anyOf entries
|
|
90
|
+
const allBsonTypes = collectBsonTypes(schemaNode);
|
|
91
|
+
if (allBsonTypes.length >= 2) {
|
|
92
|
+
entry.bsonTypes = allBsonTypes;
|
|
93
|
+
}
|
|
94
|
+
// isSparse: field was not observed in every document
|
|
95
|
+
const occurrence = schemaNode['x-occurrence'] ?? 0;
|
|
96
|
+
if (parentDocumentsInspected > 0 && occurrence < parentDocumentsInspected) {
|
|
97
|
+
entry.isSparse = true;
|
|
98
|
+
}
|
|
99
|
+
// arrayItemBsonType: for array fields, find the dominant element type
|
|
100
|
+
if (mostCommonTypeEntry.type === 'array') {
|
|
101
|
+
const itemBsonType = getDominantArrayItemBsonType(mostCommonTypeEntry);
|
|
102
|
+
if (itemBsonType) {
|
|
103
|
+
entry.arrayItemBsonType = itemBsonType;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
result.push(entry);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Sort: _id first, then alphabetical by path
|
|
111
|
+
result.sort((a, b) => {
|
|
112
|
+
if (a.path === '_id')
|
|
113
|
+
return -1;
|
|
114
|
+
if (b.path === '_id')
|
|
115
|
+
return 1;
|
|
116
|
+
return a.path.localeCompare(b.path);
|
|
117
|
+
});
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Helper function to get the most common type entry from a schema node.
|
|
122
|
+
* It looks for the 'anyOf' array and selects the type with the highest 'x-typeOccurrence'.
|
|
123
|
+
*/
|
|
124
|
+
function getMostCommonTypeEntry(schemaNode) {
|
|
125
|
+
if (schemaNode.anyOf && schemaNode.anyOf.length > 0) {
|
|
126
|
+
let maxOccurrence = -1;
|
|
127
|
+
let mostCommonTypeEntry = null;
|
|
128
|
+
for (const typeEntry of schemaNode.anyOf) {
|
|
129
|
+
const occurrence = typeEntry['x-typeOccurrence'] || 0;
|
|
130
|
+
if (occurrence > maxOccurrence) {
|
|
131
|
+
maxOccurrence = occurrence;
|
|
132
|
+
mostCommonTypeEntry = typeEntry;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return mostCommonTypeEntry;
|
|
136
|
+
}
|
|
137
|
+
else if (schemaNode.type) {
|
|
138
|
+
// If 'anyOf' is not present, use the 'type' field directly
|
|
139
|
+
return schemaNode;
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Collects all distinct x-bsonType values from a schema node's anyOf entries.
|
|
145
|
+
* Returns them sorted alphabetically for determinism.
|
|
146
|
+
*/
|
|
147
|
+
function collectBsonTypes(schemaNode) {
|
|
148
|
+
if (!schemaNode.anyOf || schemaNode.anyOf.length === 0) {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
const bsonTypes = new Set();
|
|
152
|
+
for (const entry of schemaNode.anyOf) {
|
|
153
|
+
const bsonType = entry['x-bsonType'];
|
|
154
|
+
if (bsonType) {
|
|
155
|
+
bsonTypes.add(bsonType);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return Array.from(bsonTypes).sort();
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* For an array type entry, finds the dominant element BSON type by looking at
|
|
162
|
+
* items.anyOf and selecting the entry with the highest x-typeOccurrence.
|
|
163
|
+
*/
|
|
164
|
+
function getDominantArrayItemBsonType(arrayTypeEntry) {
|
|
165
|
+
const itemsSchema = arrayTypeEntry.items;
|
|
166
|
+
if (!itemsSchema?.anyOf || itemsSchema.anyOf.length === 0) {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
let maxOccurrence = -1;
|
|
170
|
+
let dominantBsonType;
|
|
171
|
+
for (const entry of itemsSchema.anyOf) {
|
|
172
|
+
const occurrence = entry['x-typeOccurrence'] ?? 0;
|
|
173
|
+
if (occurrence > maxOccurrence) {
|
|
174
|
+
maxOccurrence = occurrence;
|
|
175
|
+
dominantBsonType = entry['x-bsonType'];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return dominantBsonType;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=getKnownFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKnownFields.js","sourceRoot":"","sources":["../src/getKnownFields.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;AA4ChG,wCAuGC;AAjJD,oDAA4B;AAwB5B;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,cAAc,CAAC,MAAkB;IAC7C,MAAM,MAAM,GAAiB,EAAE,CAAC;IAQhC,MAAM,sBAAsB,GAAI,MAAM,CAAC,sBAAsB,CAAY,IAAI,CAAC,CAAC;IAC/E,MAAM,KAAK,GAAsB,IAAI,gBAAM,EAAE,CAAC;IAE9C,4CAA4C;I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,CAAC,YAAY,CAAuB,CAAC;QAC3D,IAAI,QAAQ,EAAE,CAAC;YACX,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,SAAS,4BAA4B,CAAC,cAA0B;IAC5D,MAAM,WAAW,GAAG,cAAc,CAAC,KAA+B,CAAC;IACnE,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAI,aAAa,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,gBAAoC,CAAC;IAEzC,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,KAAqB,EAAE,CAAC;QACpD,MAAM,UAAU,GAAI,KAAK,CAAC,kBAAkB,CAAY,IAAI,CAAC,CAAC;QAC9D,IAAI,UAAU,GAAG,aAAa,EAAE,CAAC;YAC7B,aAAa,GAAG,UAAU,CAAC;YAC3B,gBAAgB,GAAG,KAAK,CAAC,YAAY,CAAuB,CAAC;QACjE,CAAC;IACL,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { BSONTypes } from './BSONTypes';
|
|
2
|
+
export { getKnownFields, type FieldEntry } from './getKnownFields';
|
|
3
|
+
export { type JSONSchema, type JSONSchemaMap, type JSONSchemaRef } from './JSONSchema';
|
|
4
|
+
export { SchemaAnalyzer, buildFullPaths, getPropertyNamesAtLevel } from './SchemaAnalyzer';
|
|
5
|
+
export { valueToDisplayString } from './ValueFormatters';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.valueToDisplayString = exports.getPropertyNamesAtLevel = exports.buildFullPaths = exports.SchemaAnalyzer = exports.getKnownFields = exports.BSONTypes = void 0;
|
|
8
|
+
var BSONTypes_1 = require("./BSONTypes");
|
|
9
|
+
Object.defineProperty(exports, "BSONTypes", { enumerable: true, get: function () { return BSONTypes_1.BSONTypes; } });
|
|
10
|
+
var getKnownFields_1 = require("./getKnownFields");
|
|
11
|
+
Object.defineProperty(exports, "getKnownFields", { enumerable: true, get: function () { return getKnownFields_1.getKnownFields; } });
|
|
12
|
+
var SchemaAnalyzer_1 = require("./SchemaAnalyzer");
|
|
13
|
+
Object.defineProperty(exports, "SchemaAnalyzer", { enumerable: true, get: function () { return SchemaAnalyzer_1.SchemaAnalyzer; } });
|
|
14
|
+
Object.defineProperty(exports, "buildFullPaths", { enumerable: true, get: function () { return SchemaAnalyzer_1.buildFullPaths; } });
|
|
15
|
+
Object.defineProperty(exports, "getPropertyNamesAtLevel", { enumerable: true, get: function () { return SchemaAnalyzer_1.getPropertyNamesAtLevel; } });
|
|
16
|
+
var ValueFormatters_1 = require("./ValueFormatters");
|
|
17
|
+
Object.defineProperty(exports, "valueToDisplayString", { enumerable: true, get: function () { return ValueFormatters_1.valueToDisplayString; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,mDAAmE;AAA1D,gHAAA,cAAc,OAAA;AAEvB,mDAA2F;AAAlF,gHAAA,cAAc,OAAA;AAAE,gHAAA,cAAc,OAAA;AAAE,yHAAA,uBAAuB,OAAA;AAChE,qDAAyD;AAAhD,uHAAA,oBAAoB,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@documentdb-js/schema-analyzer",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Incremental JSON Schema analyzer for DocumentDB API / MongoDB API documents with statistical extensions",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc -p .",
|
|
12
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
13
|
+
"test": "jest --config jest.config.js"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/microsoft/vscode-documentdb",
|
|
18
|
+
"directory": "packages/documentdb-js-schema-analyzer"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"mongodb": ">=6.0.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"denque": "~2.1.0"
|
|
26
|
+
}
|
|
27
|
+
}
|