@travetto/registry
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -18,3 +18,3 @@ { | ||
"scripts": {}, | ||
"version": "0.0.10" | ||
"version": "0.0.11" | ||
} |
@@ -22,3 +22,3 @@ import { Compiler } from '@travetto/compiler'; | ||
async init() { | ||
let files = await bulkFind(Compiler.workingSets, undefined, Compiler.invalidWorkingSetFile); | ||
const files = await bulkFind(Compiler.workingSets, undefined, Compiler.invalidWorkingSetFile); | ||
@@ -31,7 +31,7 @@ const extra: string[] = []; | ||
for (let file of files) { | ||
for (const file of files) { | ||
this.processClasses(file, this.computeClasses(file)); | ||
} | ||
for (let file of extra) { | ||
for (const file of extra) { | ||
if (PendingRegister.has(file)) { | ||
@@ -57,3 +57,3 @@ this.processClasses(file, PendingRegister.get(file)!); | ||
this.classes.set(file, new Map()); | ||
for (let cls of classes) { | ||
for (const cls of classes) { | ||
this.classes.get(file)!.set(cls.__id, cls); | ||
@@ -70,3 +70,3 @@ this.emit({ type: 'added', curr: cls }); | ||
console.debug('Got file', file); | ||
let next = new Map(this.computeClasses(file).map(x => [x.__id, x] as [string, Class])); | ||
const next = new Map(this.computeClasses(file).map(x => [x.__id, x] as [string, Class])); | ||
let prev = new Map(); | ||
@@ -77,3 +77,3 @@ if (this.classes.has(file)) { | ||
let keys = new Set([...prev.keys(), ...next.keys()]); | ||
const keys = new Set([...prev.keys(), ...next.keys()]); | ||
@@ -84,3 +84,3 @@ if (!this.classes.has(file)) { | ||
for (let k of keys) { | ||
for (const k of keys) { | ||
if (!next.has(k)) { | ||
@@ -98,5 +98,5 @@ this.emit({ type: 'removing', prev: prev.get(k)! }); | ||
try { | ||
let out = require(file); | ||
const out = require(file); | ||
// Get and clear after computed | ||
let classes: Class[] = PendingRegister.get(file)!; | ||
const classes: Class[] = PendingRegister.get(file)!; | ||
PendingRegister.delete(file); | ||
@@ -103,0 +103,0 @@ return classes || []; |
@@ -59,3 +59,3 @@ import { Registry } from './registry'; | ||
getOrCreatePending(cls: Class): Partial<C> { | ||
let cid = id(cls); | ||
const cid = id(cls); | ||
if (!this.pending.has(cid)) { | ||
@@ -79,3 +79,3 @@ this.pending.set(cid, this.createPending(cls)); | ||
register(cls: Class, pconfig: Partial<C>) { | ||
let conf = this.getOrCreatePending(cls); | ||
const conf = this.getOrCreatePending(cls); | ||
_.merge(conf, pconfig); | ||
@@ -85,3 +85,3 @@ } | ||
registerMethod(cls: Class, method: Function, pconfig: Partial<M>) { | ||
let conf = this.getOrCreatePendingMethod(cls, method); | ||
const conf = this.getOrCreatePendingMethod(cls, method); | ||
_.merge(conf, pconfig); | ||
@@ -92,3 +92,3 @@ } | ||
if (this.pending.has(cls.__id) || this.pendingMethods.has(cls.__id)) { | ||
let result = this.onInstallFinalize(cls); | ||
const result = this.onInstallFinalize(cls); | ||
this.pendingMethods.delete(cls.__id); | ||
@@ -95,0 +95,0 @@ this.pending.delete(cls.__id); |
@@ -17,3 +17,3 @@ import { Class } from '../model/types'; | ||
if (this.parents.length) { | ||
for (let parent of this.parents) { | ||
for (const parent of this.parents) { | ||
this.listen(parent); | ||
@@ -42,8 +42,8 @@ if (parent instanceof Registry) { | ||
let waitFor = this.parents.filter(x => !(x instanceof Registry)); | ||
const waitFor = this.parents.filter(x => !(x instanceof Registry)); | ||
await Promise.all(waitFor.map(x => x.init())); | ||
let classes = await this.initialInstall(); | ||
const classes = await this.initialInstall(); | ||
if (classes) { | ||
for (let cls of classes) { | ||
for (const cls of classes) { | ||
this.install(cls, { type: 'added', curr: cls }); | ||
@@ -76,3 +76,3 @@ } | ||
} | ||
for (let cls of classes) { | ||
for (const cls of classes) { | ||
this.onUninstall(cls, e); | ||
@@ -86,3 +86,3 @@ } | ||
} | ||
for (let cls of classes) { | ||
for (const cls of classes) { | ||
this.onInstall(cls, e); | ||
@@ -128,3 +128,3 @@ } | ||
this.onReset(); | ||
for (let des of this.descendents) { | ||
for (const des of this.descendents) { | ||
des.reset(); | ||
@@ -131,0 +131,0 @@ } |
@@ -17,3 +17,3 @@ import { Registry } from './registry'; | ||
onReset() { | ||
for (let parent of this.parents) { | ||
for (const parent of this.parents) { | ||
parent!.reset() | ||
@@ -20,0 +20,0 @@ } |
@@ -34,3 +34,6 @@ import * as ts from 'typescript'; | ||
return ts.updateClassDeclaration(node, | ||
ts.createNodeArray([ts.createDecorator(ts.createCall(ts.createPropertyAccess(state.imported, ts.createIdentifier('Register')), undefined, [])), ...(node.decorators || [])]), | ||
ts.createNodeArray( | ||
[ts.createDecorator( | ||
ts.createCall(ts.createPropertyAccess(state.imported, ts.createIdentifier('Register')), undefined, []) | ||
), ...(node.decorators || [])]), | ||
node.modifiers, | ||
@@ -58,3 +61,3 @@ node.name, | ||
if (fileRoot.startsWith('@')) { | ||
let [ns1, ns2, ...rest] = fileRoot.split(SEP); | ||
const [ns1, ns2, ...rest] = fileRoot.split(SEP); | ||
ns = `${ns1}.${ns2}`; | ||
@@ -61,0 +64,0 @@ fileRoot = rest.join(SEP); |
14465
412