Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8cbcaee

Browse files
authored
Remove deprecated methods and improveClass definition (#209)
1 parent92699e1 commit8cbcaee

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

‎source/index.ts‎

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,10 @@ const is = Object.assign(
236236
boundFunction:isBoundFunction,
237237
buffer:isBuffer,
238238
class:isClass,
239-
/**@deprecated Renamed to `class`. */
240-
class_:isClass,
241239
dataView:isDataView,
242240
date:isDate,
243241
detect,
244242
directInstanceOf:isDirectInstanceOf,
245-
/**@deprecated Renamed to `htmlElement` */
246-
domElement:isHtmlElement,
247243
emptyArray:isEmptyArray,
248244
emptyMap:isEmptyMap,
249245
emptyObject:isEmptyObject,
@@ -258,8 +254,6 @@ const is = Object.assign(
258254
float64Array:isFloat64Array,
259255
formData:isFormData,
260256
function:isFunction,
261-
/**@deprecated Renamed to `function`. */
262-
function_:isFunction,
263257
generator:isGenerator,
264258
generatorFunction:isGeneratorFunction,
265259
htmlElement:isHtmlElement,
@@ -282,8 +276,6 @@ const is = Object.assign(
282276
nonEmptyString:isNonEmptyString,
283277
nonEmptyStringAndNotWhitespace:isNonEmptyStringAndNotWhitespace,
284278
null:isNull,
285-
/**@deprecated Renamed to `null`. */
286-
null_:isNull,
287279
nullOrUndefined:isNullOrUndefined,
288280
number:isNumber,
289281
numericString:isNumericString,
@@ -403,7 +395,7 @@ export function isBuffer(value: unknown): value is Buffer {
403395
return(valueasany)?.constructor?.isBuffer?.(value)??false;
404396
}
405397

406-
exportfunctionisClass(value:unknown):value isClass{
398+
exportfunctionisClass<T=unknown>(value:unknown):value isClass<T>{
407399
returnisFunction(value)&&value.toString().startsWith('class ');
408400
}
409401

@@ -832,17 +824,9 @@ type Assert = {
832824
bigint:(value:unknown,message?:string)=> assertsvalue isbigint;
833825
// eslint-disable-next-line @typescript-eslint/ban-types
834826
function:(value:unknown,message?:string)=> assertsvalue isFunction;
835-
/**@deprecated Renamed to `function`. */
836-
// eslint-disable-next-line @typescript-eslint/ban-types
837-
function_:(value:unknown,message?:string)=> assertsvalue isFunction;
838827
// eslint-disable-next-line @typescript-eslint/ban-types
839828
null:(value:unknown,message?:string)=> assertsvalue isnull;
840-
/**@deprecated Renamed to `null`. */
841-
// eslint-disable-next-line @typescript-eslint/ban-types
842-
null_:(value:unknown,message?:string)=> assertsvalue isnull;
843-
class:(value:unknown,message?:string)=> assertsvalue isClass;
844-
/**@deprecated Renamed to `class`. */
845-
class_:(value:unknown,message?:string)=> assertsvalue isClass;
829+
class:<T=unknown>(value:unknown,message?:string)=> assertsvalue isClass<T>;
846830
boolean:(value:unknown,message?:string)=> assertsvalue isboolean;
847831
symbol:(value:unknown,message?:string)=> assertsvalue issymbol;
848832
numericString:(value:unknown,message?:string)=> assertsvalue is `${number}`;
@@ -902,8 +886,6 @@ type Assert = {
902886
typedArray:(value:unknown,message?:string)=> assertsvalue isTypedArray;
903887
arrayLike:<T=unknown>(value:unknown,message?:string)=> assertsvalue isArrayLike<T>;
904888
tupleLike:<TextendsArray<TypeGuard<unknown>>>(value:unknown,guards:[...T],message?:string)=> assertsvalue isResolveTypesOfTypeGuardsTuple<T>;
905-
/**@deprecated Renamed to `htmlElement` */
906-
domElement:(value:unknown,message?:string)=> assertsvalue isHTMLElement;
907889
htmlElement:(value:unknown,message?:string)=> assertsvalue isHTMLElement;
908890
observable:(value:unknown,message?:string)=> assertsvalue isObservableLike;
909891
nodeStream:(value:unknown,message?:string)=> assertsvalue isNodeStream;
@@ -958,11 +940,9 @@ export const assert: Assert = {
958940
boundFunction:assertBoundFunction,
959941
buffer:assertBuffer,
960942
class:assertClass,
961-
class_:assertClass,
962943
dataView:assertDataView,
963944
date:assertDate,
964945
directInstanceOf:assertDirectInstanceOf,
965-
domElement:assertHtmlElement,
966946
emptyArray:assertEmptyArray,
967947
emptyMap:assertEmptyMap,
968948
emptyObject:assertEmptyObject,
@@ -977,7 +957,6 @@ export const assert: Assert = {
977957
float64Array:assertFloat64Array,
978958
formData:assertFormData,
979959
function:assertFunction,
980-
function_:assertFunction,
981960
generator:assertGenerator,
982961
generatorFunction:assertGeneratorFunction,
983962
htmlElement:assertHtmlElement,
@@ -1000,7 +979,6 @@ export const assert: Assert = {
1000979
nonEmptyString:assertNonEmptyString,
1001980
nonEmptyStringAndNotWhitespace:assertNonEmptyStringAndNotWhitespace,
1002981
null:assertNull,
1003-
null_:assertNull,
1004982
nullOrUndefined:assertNullOrUndefined,
1005983
number:assertNumber,
1006984
numericString:assertNumericString,
@@ -1056,8 +1034,6 @@ const methodTypeMap = {
10561034
isDataView:'DataView',
10571035
isDate:'Date',
10581036
isDirectInstanceOf:'T',
1059-
/**@deprecated */
1060-
isDomElement:'HTMLElement',
10611037
isEmptyArray:'empty array',
10621038
isEmptyMap:'empty map',
10631039
isEmptyObject:'empty object',
@@ -1247,7 +1223,7 @@ export function assertBuffer(value: unknown, message?: string): asserts value is
12471223
}
12481224
}
12491225

1250-
exportfunctionassertClass(value:unknown,message?:string): assertsvalue isClass{
1226+
exportfunctionassertClass<T>(value:unknown,message?:string): assertsvalue isClass<T>{
12511227
if(!isClass(value)){
12521228
thrownewTypeError(message??typeErrorMessage('Class',value));
12531229
}

‎source/types.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ export type Primitive =
1515
/**
1616
Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
1717
*/
18-
///type Constructor<T, Arguments extends unknown[] = any[]> = new(...arguments_: Arguments) => T;
18+
typeConstructor<T,Argumentsextendsunknown[]=any[]>=new(...arguments_:Arguments)=>T;
1919

2020
/**
2121
Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
2222
*/
23-
// TODO: Use the below in the next major version.
24-
// export type Class<T, Arguments extends unknown[] = any[]> = Constructor<T, Arguments> & {prototype: T};
25-
exporttypeClass<T=unknown,Argumentsextendsany[]=any[]>=new(...arguments_:Arguments)=>T;
23+
exporttypeClass<T,Argumentsextendsunknown[]=any[]>=Constructor<T,Arguments>&{prototype:T};
2624

2725
/**
2826
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.

‎test/test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const types = new Map<string, Test>([
6161
}],
6262
['null',{
6363
is:is.null,
64-
assert:assert.null_,
64+
assert:assert.null,
6565
fixtures:[
6666
null,
6767
],
@@ -161,7 +161,7 @@ const types = new Map<string, Test>([
161161
}],
162162
['function',{
163163
is:is.function,
164-
assert:assert.function_,
164+
assert:assert.function,
165165
fixtures:[
166166
functionfoo(){},// eslint-disable-line func-names
167167
function(){},
@@ -840,7 +840,7 @@ test('is.asyncFunction', t => {
840840
t.true(is.function(fixture().then));
841841

842842
t.notThrows(()=>{
843-
assert.function_(fixture().then);
843+
assert.function(fixture().then);
844844
});
845845
}
846846
});
@@ -1370,7 +1370,7 @@ test('is.class', t => {
13701370
t.true(is.class(classDeclaration));
13711371

13721372
t.notThrows(()=>{
1373-
assert.class_(classDeclaration);
1373+
assert.class(classDeclaration);
13741374
});
13751375
}
13761376
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp