diff --git a/implementations/javascript/src/dictionary.ts b/implementations/javascript/src/dictionary.ts index 5343c2f..0da35e3 100644 --- a/implementations/javascript/src/dictionary.ts +++ b/implementations/javascript/src/dictionary.ts @@ -25,11 +25,10 @@ export class Dictionary extends FlexMap); - constructor(items?: Iterable) { - const iter = items?.[Symbol.iterator](); - super(canonicalString, iter === void 0 ? void 0 : _iterMap(iter, ([k,v]) => [fromJS(k), v])); + constructor(items?: readonly [Value, V][]); + constructor(items?: Iterable, V]>); + constructor(items?: Iterable, V]>) { + super(canonicalString, items); } mapEntries(f: (entry: [Value, V]) => [Value, W]): Dictionary { @@ -84,9 +83,8 @@ export class Set extends FlexSet> { return x?.[DictionaryType] === 'Set'; } - constructor(items?: Iterable) { - const iter = items?.[Symbol.iterator](); - super(canonicalString, iter === void 0 ? void 0 : _iterMap>(iter, fromJS)); + constructor(items?: Iterable>) { + super(canonicalString, items); } map(f: (value: Value) => Value): Set { diff --git a/implementations/javascript/src/record.ts b/implementations/javascript/src/record.ts index 2a02039..fc5a350 100644 --- a/implementations/javascript/src/record.ts +++ b/implementations/javascript/src/record.ts @@ -1,14 +1,14 @@ import { Tag } from "./constants"; import { Encoder } from "./codec"; import { PreserveOn } from "./symbols"; -import { DefaultPointer, fromJS, is, Value } from "./values"; +import { DefaultPointer, is, Value } from "./values"; export const IsPreservesRecord = Symbol.for('IsPreservesRecord'); export class Record extends Array> { readonly label: Value; - constructor(label: Value, fieldsJS: any[]) { + constructor(label: Value, fields: Value[]) { if (arguments.length === 1) { // Using things like someRecord.map() involves the runtime // apparently instantiating instances of this.constructor @@ -20,8 +20,8 @@ export class Record extends Array> { return; } - super(fieldsJS.length); - fieldsJS.forEach((f, i) => this[i] = fromJS(f)); + super(fields.length); + fields.forEach((f, i) => this[i] = f); this.label = label; Object.freeze(this); } @@ -72,11 +72,10 @@ export class Record extends Array> { } static makeConstructor(labelSymbolText: string, fieldNames: string[]): RecordConstructor { - return Record.makeBasicConstructor(Symbol.for(labelSymbolText), fieldNames); + return Record.makeBasicConstructor(Symbol.for(labelSymbolText), fieldNames); } - static makeBasicConstructor(label0: any, fieldNames: string[]): RecordConstructor { - const label = fromJS(label0); + static makeBasicConstructor(label: Value, fieldNames: string[]): RecordConstructor { const arity = fieldNames.length; const ctor: RecordConstructor = (...fields: any[]): Record => { if (fields.length !== arity) {