Remove TypeDesc equals (#2584)

This method was not being used.

Major Version Change: equals was part of exposed public API of *Desc
This commit is contained in:
Erik Arvidsson
2016-09-16 13:59:19 -07:00
committed by GitHub
parent 08bb4597d7
commit ee1db61bba
4 changed files with 6 additions and 58 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "@attic/noms",
"license": "Apache-2.0",
"version": "59.0.2",
"version": "60.0.0",
"description": "Noms JS SDK",
"repository": "https://github.com/attic-labs/noms",
"main": "dist/commonjs/noms.js",

View File

@@ -34,8 +34,8 @@ import {
newSetMetaSequence,
} from './meta-sequence.js';
import {
boolType,
blobType,
boolType,
makeCycleType,
makeListType,
makeMapType,
@@ -45,6 +45,7 @@ import {
numberType,
stringType,
typeType,
valueType,
} from './type.js';
import type {Type} from './type.js';
import {staticTypeCache} from './type-cache.js';
@@ -291,6 +292,7 @@ suite('Encoding', () => {
const SetKind = Kind.Set;
const StructKind = Kind.Struct;
const TypeKind = Kind.Type;
const ValueKind = Kind.Value;
const CycleKind = Kind.Cycle;
const UnionKind = Kind.Union;
@@ -319,6 +321,7 @@ suite('Encoding', () => {
test('types', () => {
assertEncoding([uint8(TypeKind), uint8(BoolKind)], boolType);
assertEncoding([uint8(TypeKind), uint8(TypeKind)], typeType);
assertEncoding([uint8(TypeKind), uint8(ValueKind)], valueType);
assertEncoding([uint8(TypeKind), uint8(ListKind), uint8(BoolKind)], makeListType(boolType));
assertEncoding([uint8(TypeKind), uint8(SetKind), uint8(StringKind)], makeSetType(stringType));
assertEncoding([uint8(TypeKind), uint8(MapKind), uint8(StringKind), uint8(NumberKind)], makeMapType(stringType, numberType));

View File

@@ -279,9 +279,8 @@ function computeTypeForStruct(name: string, data: StructData): Type<StructDesc>
* Returns the field names which have different values in the respective structs.
*/
export function structDiff(s1: Struct, s2: Struct): string[] {
invariant(equals(s1.type, s2.type));
const desc1: StructDesc = s1.type.desc;
const desc2: StructDesc = s2.type.desc;
invariant(desc1.equals(desc2));
const changed = [];
desc1.fields.forEach((f: Field, i: number) => {

View File

@@ -11,14 +11,12 @@ import {invariant, notNull} from './assert.js';
import {isPrimitiveKind, Kind} from './noms-kind.js';
import {ValueBase} from './value.js';
import type Value from './value.js';
import {equals} from './compare.js';
import {describeType} from './encode-human-readable.js';
import search from './binary-search.js';
import {staticTypeCache} from './type-cache.js';
export interface TypeDesc {
kind: NomsKind;
equals(other: TypeDesc): boolean;
hasUnresolvedCycle(visited: Type<any>[]): boolean;
}
@@ -29,10 +27,6 @@ export class PrimitiveDesc {
this.kind = kind;
}
equals(other: TypeDesc): boolean {
return other instanceof PrimitiveDesc && other.kind === this.kind;
}
hasUnresolvedCycle(visited: Type<any>[]): boolean { // eslint-disable-line no-unused-vars
return false;
}
@@ -47,24 +41,6 @@ export class CompoundDesc {
this.elemTypes = elemTypes;
}
equals(other: TypeDesc): boolean {
if (other instanceof CompoundDesc) {
if (this.kind !== other.kind || this.elemTypes.length !== other.elemTypes.length) {
return false;
}
for (let i = 0; i < this.elemTypes.length; i++) {
if (!equals(this.elemTypes[i], other.elemTypes[i])) {
return false;
}
}
return true;
}
return false;
}
hasUnresolvedCycle(visited: Type<any>[]): boolean {
return this.elemTypes.some(t => t.hasUnresolvedCycle(visited));
}
@@ -92,32 +68,6 @@ export class StructDesc {
return Kind.Struct;
}
equals(other: TypeDesc): boolean {
if (this === other) {
return true;
}
if (other.kind !== this.kind) {
return false;
}
invariant(other instanceof StructDesc);
const fields = this.fields;
const otherFields = other.fields;
if (fields.length !== otherFields.length) {
return false;
}
for (let i = 0; i < fields.length; i++) {
if (fields[i].name !== otherFields[i].name || !equals(fields[i].type, otherFields[i].type)) {
return false;
}
}
return true;
}
hasUnresolvedCycle(visited: Type<any>[]): boolean {
return this.fields.some(f => f.type.hasUnresolvedCycle(visited));
}
@@ -159,10 +109,6 @@ export class CycleDesc {
return Kind.Cycle;
}
equals(other: TypeDesc): boolean {
return other instanceof CycleDesc && other.level === this.level;
}
hasUnresolvedCycle(visited: Type<any>[]): boolean { // eslint-disable-line no-unused-vars
return true;
}