Debian Codegraph @

debian/tests/test_modules/incomplete-symbol/lib/index.js

raw symbols SCIP
1 "use strict";
2 const {instanceMethods, instanceProperties, staticMethods, staticProperties} = require("./props");
3
4
5
6 const customizeSymbol = (exclusions=[]) =>
7 {
8 // For testing: uses the global value when this function is called
9 // instead of when instances are created
10 const globalSymbol = Symbol;
11
12 function IncompleteSymbolInstance(description)
13 {
14 this._symbol = globalSymbol(description);
15
16 instanceMethods
17 .filter(method => !exclusions.includes(method) && typeof this._symbol[method]==="function")
18 .forEach(method => this[method] = (...args) => this._symbol[method](...args));
19
20 instanceProperties
21 .filter(property => !exclusions.includes(property) && this._symbol[property]!==undefined)
22 .forEach(property => Object.defineProperty(this, property,
23 {
24 get: () => this._symbol[property]
25 }));
26 }
27
28 const IncompleteSymbol = (...args) => new IncompleteSymbolInstance(...args);
29
30 staticMethods
31 .filter(method => !exclusions.includes(method) && typeof globalSymbol[method]==="function")
32 .forEach(method => IncompleteSymbol[method] = (...args) => globalSymbol[method](...args));
33
34 staticProperties
35 .filter(property => !exclusions.includes(property) && property in globalSymbol)
36 .forEach(property => Object.defineProperty(IncompleteSymbol, property,
37 {
38 get: () => globalSymbol[property]
39 }));
40
41 return IncompleteSymbol;
42 };
43
44
45
46 module.exports = customizeSymbol;