occam-model 1.0.484

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.
Files changed (66) hide show
  1. package/.swcrc +5 -0
  2. package/README.md +78 -0
  3. package/lib/constants.js +34 -0
  4. package/lib/dependencies.js +114 -0
  5. package/lib/dependency.js +81 -0
  6. package/lib/directory.js +107 -0
  7. package/lib/entries.js +245 -0
  8. package/lib/file.js +162 -0
  9. package/lib/fileNames.js +49 -0
  10. package/lib/files.js +121 -0
  11. package/lib/index.js +83 -0
  12. package/lib/mixins/bnf.js +43 -0
  13. package/lib/mixins/entries.js +99 -0
  14. package/lib/mixins/files.js +46 -0
  15. package/lib/mixins/metaJSON.js +36 -0
  16. package/lib/mixins/vocabulary.js +43 -0
  17. package/lib/multiplers.js +26 -0
  18. package/lib/project.js +98 -0
  19. package/lib/projects.js +112 -0
  20. package/lib/propertyNames.js +26 -0
  21. package/lib/release.js +152 -0
  22. package/lib/releases.js +112 -0
  23. package/lib/shortenedVersion.js +105 -0
  24. package/lib/types.js +22 -0
  25. package/lib/utilities/content.js +42 -0
  26. package/lib/utilities/filePath.js +105 -0
  27. package/lib/utilities/files.js +99 -0
  28. package/lib/utilities/metaJSON.js +197 -0
  29. package/lib/utilities/name.js +18 -0
  30. package/lib/utilities/query.js +36 -0
  31. package/lib/utilities/validate.js +26 -0
  32. package/lib/utilities/version.js +71 -0
  33. package/lib/version.js +160 -0
  34. package/license.txt +48 -0
  35. package/package.json +34 -0
  36. package/src/constants.js +7 -0
  37. package/src/dependencies.js +65 -0
  38. package/src/dependency.js +43 -0
  39. package/src/directory.js +60 -0
  40. package/src/entries.js +206 -0
  41. package/src/file.js +113 -0
  42. package/src/fileNames.js +18 -0
  43. package/src/files.js +66 -0
  44. package/src/index.js +18 -0
  45. package/src/mixins/bnf.js +51 -0
  46. package/src/mixins/entries.js +69 -0
  47. package/src/mixins/files.js +61 -0
  48. package/src/mixins/metaJSON.js +44 -0
  49. package/src/mixins/vocabulary.js +51 -0
  50. package/src/multiplers.js +5 -0
  51. package/src/project.js +63 -0
  52. package/src/projects.js +54 -0
  53. package/src/propertyNames.js +5 -0
  54. package/src/release.js +151 -0
  55. package/src/releases.js +54 -0
  56. package/src/shortenedVersion.js +71 -0
  57. package/src/types.js +4 -0
  58. package/src/utilities/content.js +22 -0
  59. package/src/utilities/filePath.js +66 -0
  60. package/src/utilities/files.js +114 -0
  61. package/src/utilities/metaJSON.js +254 -0
  62. package/src/utilities/name.js +13 -0
  63. package/src/utilities/query.js +25 -0
  64. package/src/utilities/validate.js +5 -0
  65. package/src/utilities/version.js +70 -0
  66. package/src/version.js +123 -0
package/lib/version.js ADDED
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Version;
9
+ }
10
+ });
11
+ var _multiplers = require("./multiplers");
12
+ var _version = require("./utilities/version");
13
+ function _class_call_check(instance, Constructor) {
14
+ if (!(instance instanceof Constructor)) {
15
+ throw new TypeError("Cannot call a class as a function");
16
+ }
17
+ }
18
+ function _defineProperties(target, props) {
19
+ for(var i = 0; i < props.length; i++){
20
+ var descriptor = props[i];
21
+ descriptor.enumerable = descriptor.enumerable || false;
22
+ descriptor.configurable = true;
23
+ if ("value" in descriptor) descriptor.writable = true;
24
+ Object.defineProperty(target, descriptor.key, descriptor);
25
+ }
26
+ }
27
+ function _create_class(Constructor, protoProps, staticProps) {
28
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
29
+ if (staticProps) _defineProperties(Constructor, staticProps);
30
+ return Constructor;
31
+ }
32
+ var Version = /*#__PURE__*/ function() {
33
+ function Version(majorNumber, minorNumber, patchNumber) {
34
+ _class_call_check(this, Version);
35
+ this.majorNumber = majorNumber;
36
+ this.minorNumber = minorNumber;
37
+ this.patchNumber = patchNumber;
38
+ }
39
+ _create_class(Version, [
40
+ {
41
+ key: "getMajorNumber",
42
+ value: function getMajorNumber() {
43
+ return this.majorNumber;
44
+ }
45
+ },
46
+ {
47
+ key: "getMinorNumber",
48
+ value: function getMinorNumber() {
49
+ return this.minorNumber;
50
+ }
51
+ },
52
+ {
53
+ key: "getPatchNumber",
54
+ value: function getPatchNumber() {
55
+ return this.patchNumber;
56
+ }
57
+ },
58
+ {
59
+ key: "bumpMajorNumber",
60
+ value: function bumpMajorNumber() {
61
+ this.majorNumber += 1;
62
+ }
63
+ },
64
+ {
65
+ key: "bumpMinorNumber",
66
+ value: function bumpMinorNumber() {
67
+ this.minorNumber += 1;
68
+ }
69
+ },
70
+ {
71
+ key: "bumpPatchNumber",
72
+ value: function bumpPatchNumber() {
73
+ this.patchNumber += 1;
74
+ }
75
+ },
76
+ {
77
+ key: "resetMajorNumber",
78
+ value: function resetMajorNumber() {
79
+ this.majorNumber = 0;
80
+ }
81
+ },
82
+ {
83
+ key: "resetMinorNumber",
84
+ value: function resetMinorNumber() {
85
+ this.minorNumber = 0;
86
+ }
87
+ },
88
+ {
89
+ key: "resetPatchNumber",
90
+ value: function resetPatchNumber() {
91
+ this.patchNumber = 0;
92
+ }
93
+ },
94
+ {
95
+ key: "matchShortenedVersion",
96
+ value: function matchShortenedVersion(shortenedVersion) {
97
+ var matchesShortenedVersion = false;
98
+ if (shortenedVersion === null) {
99
+ matchesShortenedVersion = true;
100
+ } else {
101
+ var majorNumber = shortenedVersion.getMajorNumber();
102
+ if (this.majorNumber === majorNumber) {
103
+ var minorNumber = shortenedVersion.getMinorNumber();
104
+ if (this.minorNumber >= minorNumber) {
105
+ matchesShortenedVersion = true;
106
+ }
107
+ }
108
+ }
109
+ return matchesShortenedVersion;
110
+ }
111
+ },
112
+ {
113
+ key: "toString",
114
+ value: function toString() {
115
+ var string = "".concat(this.majorNumber, ".").concat(this.minorNumber, ".").concat(this.patchNumber);
116
+ return string;
117
+ }
118
+ },
119
+ {
120
+ key: "toVersionNumber",
121
+ value: function toVersionNumber() {
122
+ var versionNumber = this.majorNumber * _multiplers.MAJOR_NUMBER_MULTIPLIER + this.minorNumber * _multiplers.MINOR_NUMBER_MULTIPLIER + this.patchNumber * _multiplers.PATCH_NUMBER_MULTIPLIER;
123
+ return versionNumber;
124
+ }
125
+ }
126
+ ], [
127
+ {
128
+ key: "fromString",
129
+ value: function fromString(string) {
130
+ var majorNumber = (0, _version.majorNumberFromString)(string), minorNumber = (0, _version.minorNumberFromString)(string), patchNumber = (0, _version.patchNumberFromString)(string), version = new Version(majorNumber, minorNumber, patchNumber);
131
+ return version;
132
+ }
133
+ },
134
+ {
135
+ key: "fromNothing",
136
+ value: function fromNothing() {
137
+ var majorNumber = 0, minorNumber = 0, patchNumber = 0, version = new Version(majorNumber, minorNumber, patchNumber);
138
+ return version;
139
+ }
140
+ },
141
+ {
142
+ key: "fromVersion",
143
+ value: function fromVersion(version) {
144
+ var majorNumber = version.getMajorNumber(), minorNumber = version.getMinorNumber(), patchNumber = version.getPatchNumber();
145
+ version = new Version(majorNumber, minorNumber, patchNumber); ///
146
+ return version;
147
+ }
148
+ },
149
+ {
150
+ key: "fromVersionNumber",
151
+ value: function fromVersionNumber(versionNumber) {
152
+ var number = versionNumber, majorNumber = (0, _version.majorNumberFromNumber)(number), minorNumber = (0, _version.minorNumberFromNumber)(number), patchNumber = (0, _version.patchNumberFromNumber)(number), version = new Version(majorNumber, minorNumber, patchNumber);
153
+ return version;
154
+ }
155
+ }
156
+ ]);
157
+ return Version;
158
+ }();
159
+
160
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy92ZXJzaW9uLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIlwidXNlIHN0cmljdFwiO1xuXG5pbXBvcnQgeyBNQUpPUl9OVU1CRVJfTVVMVElQTElFUiwgTUlOT1JfTlVNQkVSX01VTFRJUExJRVIsIFBBVENIX05VTUJFUl9NVUxUSVBMSUVSIH0gZnJvbSBcIi4vbXVsdG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UFBLDhCQUFxQixFQUFDRCxTQUNwQzdCLGNBQWMrQixJQUFBQSw4QkFBcUIsRUFBQ0YsU0FDcEM1QixjQUFjK0IsSUFBQUEsOEJBQXFCLEVBQUNILFNBQ3BDSixVQUFVLElBNUdDM0IsUUE0R1dDLGFBQWFDLGFBQWFDO2dCQUV0RCxPQUFPd0I7WUFDVDs7O1dBL0dtQjNCIn0=
package/license.txt ADDED
@@ -0,0 +1,48 @@
1
+ MIT And Anti-996 Licenses
2
+
3
+ Copyright (c) 2023 James Smith
4
+
5
+ These licenses shall be included in all copies or substantial portions of
6
+ this software and associated documentation files (the "Software").
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this Software, to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to permit
12
+ persons to whom the Software is furnished to do so, subject to the following
13
+ conditions:
14
+
15
+ 1. The individual or the legal entity must conspicuously display,
16
+ without modification, this License and the notice on each redistributed
17
+ or derivative copy of the Licensed Work.
18
+
19
+ 2. The individual or the legal entity must strictly comply with all
20
+ applicable laws, regulations, rules and standards of the jurisdiction
21
+ relating to labor and employment where the individual is physically
22
+ located or where the individual was born or naturalized; or where the
23
+ legal entity is registered or is operating (whichever is stricter). In
24
+ case that the jurisdiction has no such laws, regulations, rules and
25
+ standards or its laws, regulations, rules and standards are
26
+ unenforceable, the individual or the legal entity are required to
27
+ comply with Core International Labor Standards.
28
+
29
+ 3. The individual or the legal entity shall not induce, suggest or force
30
+ its employee(s), whether full-time or part-time, or its independent
31
+ contractor(s), in any methods, to agree in oral or written form, to
32
+ directly or indirectly restrict, weaken or relinquish his or her
33
+ rights or remedies under such laws, regulations, rules and standards
34
+ relating to labor and employment as mentioned above, no matter whether
35
+ such written or oral agreements are enforceable under the laws of the
36
+ said jurisdiction, nor shall such individual or the legal entity
37
+ limit, in any methods, the rights of its employee(s) or independent
38
+ contractor(s) from reporting or complaining to the copyright holder or
39
+ relevant authorities monitoring the compliance of the license about
40
+ its violation(s) of the said license.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "occam-model",
3
+ "author": "James Smith",
4
+ "version": "1.0.484",
5
+ "license": "MIT, Anti-996",
6
+ "homepage": "https://github.com/djalbat/occam-model",
7
+ "description": "Parts of Occam's model.",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/djalbat/occam-model"
11
+ },
12
+ "dependencies": {
13
+ "necessary": "^17.0.9",
14
+ "occam-grammars": "^1.3.510",
15
+ "occam-query": "^4.1.142"
16
+ },
17
+ "devDependencies": {
18
+ "@swc/core": "1.13.20",
19
+ "watchful-cli": "^1.7.67"
20
+ },
21
+ "scripts": {
22
+ "clean": "rm -rf ./lib",
23
+ "watchful": "watchful -m --transpiler=swc --source-directory=./src --lib-directory=./lib",
24
+ "batch": "npm run watchful batch --",
25
+ "batch-debug": "npm run watchful batch -- --debug",
26
+ "incremental": "npm run watchful incremental --",
27
+ "incremental-debug": "npm run watchful incremental -- --debug",
28
+ "build": "npm run clean && npm run batch",
29
+ "build-debug": "npm run clean && npm run batch-debug",
30
+ "watch": "npm run clean && npm run batch && npm run incremental",
31
+ "watch-debug": "npm run clean && npm run batch-debug && npm run incremental-debug"
32
+ },
33
+ "main": "./lib/index.js"
34
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ export const EMPTY_STRING = "";
4
+ export const DOUBLE_SPACE = " ";
5
+ export const ESCAPED_AMPERSAND = "&amp;";
6
+ export const ESCAPED_LESS_THAN = "&lt;";
7
+ export const ESCAPED_GREATER_THAN = "&gt;";
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ import { asynchronousUtilities } from "necessary";
4
+
5
+ import Dependency from "./dependency";
6
+ import ShortenedVersion from "./shortenedVersion";
7
+
8
+ const { forEach } = asynchronousUtilities;
9
+
10
+ export default class Dependencies {
11
+ constructor(array) {
12
+ this.array = array;
13
+ }
14
+
15
+ addDependency(dependency) { this.array.push(dependency); }
16
+
17
+ mapDependency(callback) { return this.array.map(callback); }
18
+
19
+ everyDependency(callback) { return this.array.every(callback); }
20
+
21
+ reduceDependency(callback, initialValue) { return this.array.reduce(callback, initialValue); }
22
+
23
+ forEachDependency(callback) { this.array.forEach(callback); }
24
+
25
+ asynchronousForEachDependency(operation, done) { forEach(this.array, operation, done); }
26
+
27
+ toJSON() {
28
+ const dependenciesJSON = this.array.reduce((dependenciesJSON, dependency) => {
29
+ const name = dependency.getName(),
30
+ shortenedVersion = dependency.getShortedVersion(),
31
+ shortenedVersionString = shortenedVersion.toString();
32
+
33
+ dependenciesJSON[name] = shortenedVersionString;
34
+
35
+ return dependenciesJSON;
36
+ }, {}),
37
+ json = dependenciesJSON; ///
38
+
39
+ return json;
40
+ }
41
+
42
+ static fromJSON(json) {
43
+ const dependenciesJSON = json, ///
44
+ dependenciesJSONKeys = Object.keys(dependenciesJSON),
45
+ names = dependenciesJSONKeys, ///
46
+ array = names.map((name) => {
47
+ const shortenedVersionString = dependenciesJSON[name],
48
+ string = shortenedVersionString, ///
49
+ shortenedVersion = ShortenedVersion.fromString(string),
50
+ dependency = Dependency.fromNameAndShortenedVersion(name, shortenedVersion);
51
+
52
+ return dependency;
53
+ }),
54
+ dependencies = new Dependencies(array);
55
+
56
+ return dependencies;
57
+ }
58
+
59
+ static fromNothing() {
60
+ const array = [],
61
+ dependencies = new Dependencies(array);
62
+
63
+ return dependencies;
64
+ }
65
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ export default class Dependency {
4
+ constructor(name, shortenedVersion) {
5
+ this.name = name;
6
+ this.shortenedVersion = shortenedVersion;
7
+ }
8
+
9
+ getName() {
10
+ return this.name;
11
+ }
12
+
13
+ getShortedVersion() {
14
+ return this.shortenedVersion;
15
+ }
16
+
17
+ asString() {
18
+ let string;
19
+
20
+ if (this.shortenedVersion !== null) {
21
+ const shortenedVersionString = this.shortenedVersion.toString();
22
+
23
+ string = `${this.name}@${shortenedVersionString}`;
24
+ } else {
25
+ string = this.name; ///
26
+ }
27
+
28
+ return string;
29
+ }
30
+
31
+ static fromName(name) {
32
+ const shortenedVersion = null,
33
+ dependency = new Dependency(name, shortenedVersion);
34
+
35
+ return dependency;
36
+ }
37
+
38
+ static fromNameAndShortenedVersion(name, shortenedVersion) {
39
+ const dependency = new Dependency(name, shortenedVersion);
40
+
41
+ return dependency;
42
+ }
43
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ import { DIRECTORY_TYPE } from "./types";
4
+
5
+ export default class Directory {
6
+ constructor(path) {
7
+ this.path = path;
8
+ }
9
+
10
+ getPath() {
11
+ return this.path;
12
+ }
13
+
14
+ isFile() {
15
+ const file = false;
16
+
17
+ return file;
18
+ }
19
+
20
+ isDirectory() {
21
+ const directory = true;
22
+
23
+ return directory;
24
+ }
25
+
26
+ toJSON() {
27
+ const { type } = Directory,
28
+ path = this.path,
29
+ json = {
30
+ type,
31
+ path
32
+ };
33
+
34
+ return json;
35
+ }
36
+
37
+ static type = DIRECTORY_TYPE;
38
+
39
+ static fromPath(path) {
40
+ const directory = new Directory(path);
41
+
42
+ return directory;
43
+ }
44
+
45
+ static fromJSON(json) {
46
+ let directory = null;
47
+
48
+ if (json !== null) {
49
+ const { type } = json;
50
+
51
+ if (type === DIRECTORY_TYPE) {
52
+ const { path } = json;
53
+
54
+ directory = new Directory(path);
55
+ }
56
+ }
57
+
58
+ return directory;
59
+ }
60
+ }
package/src/entries.js ADDED
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+
3
+ import { pathUtilities, arrayUtilities } from "necessary";
4
+
5
+ import File from "./file";
6
+ import Files from "./files";
7
+ import Directory from "./directory";
8
+ import bnfMixins from "./mixins/bnf";
9
+ import filesMixins from "./mixins/files";
10
+ import metaJSONMixins from "./mixins/metaJSON";
11
+ import vocabularyMixins from "./mixins/vocabulary";
12
+
13
+ const { first, filter } = arrayUtilities,
14
+ { topmostDirectoryNameFromPath } = pathUtilities;
15
+
16
+ class Entries {
17
+ constructor(array) {
18
+ this.array = array;
19
+ }
20
+
21
+ getTopmostDirectoryName() {
22
+ let topmostDirectoryName = null;
23
+
24
+ const firstEntry = first(this.array); ///
25
+
26
+ if (firstEntry) { ///
27
+ const firstEntryPath = firstEntry.getPath();
28
+
29
+ topmostDirectoryName = topmostDirectoryNameFromPath(firstEntryPath);
30
+
31
+ if (topmostDirectoryName === null) {
32
+ topmostDirectoryName = firstEntryPath; ///
33
+ }
34
+ }
35
+
36
+ return topmostDirectoryName;
37
+ }
38
+
39
+ removeFileByPath(path) {
40
+ filter(this.array, (entry) => {
41
+ const entryFile = entry.isFile();
42
+
43
+ if (entryFile) {
44
+ const file = entry, ///
45
+ filePath = file.getPath();
46
+
47
+ if (filePath === path) {
48
+ return false;
49
+ }
50
+ }
51
+
52
+ return true;
53
+ });
54
+ }
55
+
56
+ findFile(filePath) {
57
+ const files = this.getFiles(),
58
+ file = files.findFile((file) => {
59
+ const filePathMatches = file.matchFilePath(filePath);
60
+
61
+ if (filePathMatches) {
62
+ return true;
63
+ }
64
+ }) || null;
65
+
66
+ return file;
67
+ }
68
+
69
+ getFiles() {
70
+ const files = Files.fromNothing();
71
+
72
+ this.mapEntry((entry) => {
73
+ const entryFile = entry.isFile();
74
+
75
+ if (entryFile) {
76
+ const file = entry; ///
77
+
78
+ files.addFile(file);
79
+ }
80
+ });
81
+
82
+ return files;
83
+ }
84
+
85
+ getFilePaths() {
86
+ const filePaths = this.reduceEntry((filePaths, entry) => {
87
+ const entryFile = entry.isFile();
88
+
89
+ if (entryFile) {
90
+ const file = entry, ///
91
+ filePath = file.getPath();
92
+
93
+ filePaths.push(filePath);
94
+ }
95
+
96
+ return filePaths;
97
+ }, []);
98
+
99
+ return filePaths;
100
+ }
101
+
102
+ getDirectoryPaths() {
103
+ const directoryPaths = this.reduceEntry((directoryPaths, entry) => {
104
+ const entryDirectory = entry.isDirectory();
105
+
106
+ if (entryDirectory) {
107
+ const directory = entry, ///
108
+ directoryPath = directory.getPath();
109
+
110
+ directoryPaths.push(directoryPath);
111
+ }
112
+
113
+ return directoryPaths;
114
+ }, []);
115
+
116
+ return directoryPaths;
117
+ }
118
+
119
+ matchShortenedVersion(shortenedVersion) {
120
+ const version = this.getVersion(),
121
+ versionMatchesShortenedVersion = version.matchShortenedVersion(shortenedVersion);
122
+
123
+ return versionMatchesShortenedVersion;
124
+ }
125
+
126
+ addFile(file) {
127
+ const entry = file; ///
128
+
129
+ this.addEntry(entry);
130
+ }
131
+
132
+ addEntry(entry) { this.array.push(entry); }
133
+
134
+ addDirectory(directory) {
135
+ const entry = directory; ///
136
+
137
+ this.addEntry(entry);
138
+ }
139
+
140
+ forEachFile(callback) {
141
+ const files = this.getFiles();
142
+
143
+ files.forEachFile(callback);
144
+ }
145
+
146
+ mapEntry(callback) { return this.array.map(callback); }
147
+
148
+ someEntry(callback) { return this.array.some(callback); }
149
+
150
+ everyEntry(callback) { return this.array.every(callback); }
151
+
152
+ forEachEntry(callback) { this.array.forEach(callback); }
153
+
154
+ reduceEntry(callback, initialValue) { return this.array.reduce(callback, initialValue); }
155
+
156
+ toJSON() {
157
+ const entriesJSON = this.array.map((entry) => {
158
+ const entryJSON = entry.toJSON();
159
+
160
+ return entryJSON;
161
+ }),
162
+ json = entriesJSON; ///
163
+
164
+ return json;
165
+ }
166
+
167
+ static fromJSON(json) {
168
+ const array = [],
169
+ entries = new Entries(array),
170
+ entriesJSON = json; ///
171
+
172
+ entriesJSON.map((entryJSON) => {
173
+ const json = entryJSON, ///
174
+ file = File.fromJSON(json),
175
+ directory = Directory.fromJSON(json),
176
+ entry = file || directory; ///
177
+
178
+ entries.addEntry(entry);
179
+ });
180
+
181
+ return entries;
182
+ }
183
+
184
+ static fromEntry(entry) {
185
+ const array = [
186
+ entry
187
+ ],
188
+ entries = new Entries(array);
189
+
190
+ return entries;
191
+ }
192
+
193
+ static fromNothing() {
194
+ const array = [],
195
+ entries = new Entries(array);
196
+
197
+ return entries;
198
+ }
199
+ }
200
+
201
+ Object.assign(Entries.prototype, bnfMixins);
202
+ Object.assign(Entries.prototype, filesMixins);
203
+ Object.assign(Entries.prototype, metaJSONMixins);
204
+ Object.assign(Entries.prototype, vocabularyMixins);
205
+
206
+ export default Entries;