mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-14 10:09:09 -06:00
js sdk: expose type.describe() for convenience (#1667)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@attic/noms",
|
||||
"version": "41.3.0",
|
||||
"version": "41.4.0",
|
||||
"description": "Noms JS SDK",
|
||||
"repository": "https://github.com/attic-labs/noms",
|
||||
"main": "dist/commonjs/noms.js",
|
||||
|
||||
@@ -121,4 +121,16 @@ suite('Type', () => {
|
||||
assertValid('a_');
|
||||
assertValid('a0_');
|
||||
});
|
||||
|
||||
test('type.describe', () => {
|
||||
// This is tested exaustively as part of HRS, just testing here that
|
||||
// type.describe() is present and works.
|
||||
[
|
||||
[numberType, 'Number'],
|
||||
[stringType, 'String'],
|
||||
[makeSetType(numberType), 'Set<Number>'],
|
||||
].forEach(([t, desc]) => {
|
||||
assert.equal(t.describe(), desc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import {isPrimitiveKind, Kind} from './noms-kind.js';
|
||||
import {ValueBase} from './value.js';
|
||||
import type Value from './value.js';
|
||||
import {compare, equals} from './compare.js';
|
||||
import {describeType} from './encode-human-readable.js';
|
||||
|
||||
export interface TypeDesc {
|
||||
kind: NomsKind;
|
||||
@@ -142,6 +143,10 @@ export class Type<T: TypeDesc> extends ValueBase {
|
||||
invariant(this._desc instanceof CompoundDesc);
|
||||
return this._desc.elemTypes;
|
||||
}
|
||||
|
||||
describe(): string {
|
||||
return describeType(this);
|
||||
}
|
||||
}
|
||||
|
||||
function buildType<T: TypeDesc>(desc: T): Type<T> {
|
||||
|
||||
Reference in New Issue
Block a user