Align Range/RangeInclusive handling with other definitions (#4489)
* Align Range/RangeInclusive handling with other definitions * Split RangeInclusive class * Rnage -> Range TypeDef * Correct Range wrappers * CHANGELOG * Remove extra Range CHANGELOG entry * Update CHANGELOG.md
This commit is contained in:
@@ -53,17 +53,3 @@ export class Range<T extends INumber> extends Tuple {
|
||||
return `${this.#rangeName}<${this.start.toRawType()}>`;
|
||||
}
|
||||
}
|
||||
|
||||
export class RangeInclusive<T extends INumber = INumber> extends Range<T> {
|
||||
constructor (registry: Registry, Type: CodecClass<T> | string, value?: AnyTuple) {
|
||||
super(registry, Type, value, 'RangeInclusive');
|
||||
}
|
||||
|
||||
public static override with <T extends INumber> (Type: CodecClass<T> | string): CodecClass<RangeInclusive<T>> {
|
||||
return class extends RangeInclusive<T> {
|
||||
constructor (registry: Registry, value?: AnyTuple) {
|
||||
super(registry, Type, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AnyTuple, CodecClass, INumber, Registry } from '../types';
|
||||
|
||||
import { Range } from './Range';
|
||||
|
||||
export class RangeInclusive<T extends INumber = INumber> extends Range<T> {
|
||||
constructor (registry: Registry, Type: CodecClass<T> | string, value?: AnyTuple) {
|
||||
super(registry, Type, value, 'RangeInclusive');
|
||||
}
|
||||
|
||||
public static override with <T extends INumber> (Type: CodecClass<T> | string): CodecClass<RangeInclusive<T>> {
|
||||
return class extends RangeInclusive<T> {
|
||||
constructor (registry: Registry, value?: AnyTuple) {
|
||||
super(registry, Type, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ export { Bytes } from './Bytes';
|
||||
export { HashMap } from './HashMap';
|
||||
export { Linkage } from './Linkage';
|
||||
export { CodecMap, CodecMap as Map } from './Map';
|
||||
export { Range, RangeInclusive } from './Range';
|
||||
export { Range } from './Range';
|
||||
export { RangeInclusive } from './RangeInclusive';
|
||||
export { Type } from './Type';
|
||||
export { U8aFixed } from './U8aFixed';
|
||||
export { WrapperKeepOpaque } from './WrapperKeepOpaque';
|
||||
|
||||
Reference in New Issue
Block a user