mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #31652 from BendingBender/base-x
[base-x] Update types to v3
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
import * as baseX from 'base-x';
|
||||
|
||||
import * as basex from 'base-x';
|
||||
const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
const bs58 = baseX(BASE58);
|
||||
|
||||
let bs16 = basex('0123456789ABCDEF');
|
||||
const decoded = bs58.decode('5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr');
|
||||
decoded; // $ExpectType Buffer
|
||||
bs58.decodeUnsafe('5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr'); // $ExpectType Buffer | undefined
|
||||
|
||||
{
|
||||
let encoded: string;
|
||||
|
||||
encoded = bs16.encode([255]);
|
||||
encoded = bs16.encode({0: 255, length: 1});
|
||||
}
|
||||
|
||||
let decoded: number[] = bs16.decode('FF');
|
||||
bs58.encode(decoded); // $ExpectType string
|
||||
|
||||
Vendored
+13
-15
@@ -1,23 +1,21 @@
|
||||
// Type definitions for base-x v1.0.1
|
||||
// Type definitions for base-x 3.0
|
||||
// Project: https://github.com/cryptocoinjs/base-x
|
||||
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var BaseX: BaseX.Base;
|
||||
export = BaseX;
|
||||
/// <reference types="node" />
|
||||
|
||||
declare namespace BaseX {
|
||||
interface EncodeBuffer {
|
||||
[index: number]: number;
|
||||
length: number;
|
||||
}
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
interface BaseConverter {
|
||||
encode: (buffer: EncodeBuffer) => string;
|
||||
decode: (string: string) => number[];
|
||||
}
|
||||
export = baseX;
|
||||
|
||||
interface Base {
|
||||
(ALPHABET: string): BaseX.BaseConverter
|
||||
}
|
||||
declare function baseX(ALPHABET: string): baseX.BaseConverter;
|
||||
|
||||
declare namespace baseX {
|
||||
interface BaseConverter {
|
||||
encode(buffer: Buffer): string;
|
||||
decodeUnsafe(string: string): Buffer | undefined;
|
||||
decode(string: string): Buffer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"base-x-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as basex from 'base-x';
|
||||
|
||||
const bs16 = basex('0123456789ABCDEF');
|
||||
|
||||
{
|
||||
let encoded: string;
|
||||
|
||||
encoded = bs16.encode([255]);
|
||||
encoded = bs16.encode({0: 255, length: 1});
|
||||
}
|
||||
|
||||
const decoded: number[] = bs16.decode('FF');
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// Type definitions for base-x 1.0
|
||||
// Project: https://github.com/cryptocoinjs/base-x
|
||||
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var BaseX: BaseX.Base;
|
||||
export = BaseX;
|
||||
|
||||
declare namespace BaseX {
|
||||
interface EncodeBuffer {
|
||||
[index: number]: number;
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface BaseConverter {
|
||||
encode: (buffer: EncodeBuffer) => string;
|
||||
decode: (string: string) => number[];
|
||||
}
|
||||
|
||||
type Base = (ALPHABET: string) => BaseConverter;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"base-x": [
|
||||
"base-x/v1"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"base-x-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
-2
@@ -3,8 +3,6 @@
|
||||
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="base-x" />
|
||||
|
||||
import * as BaseX from 'base-x';
|
||||
|
||||
declare namespace base58 { }
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"base-x": [
|
||||
"base-x/v1"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
@@ -20,4 +25,4 @@
|
||||
"index.d.ts",
|
||||
"bs58-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user