66 isArray ,
77 isMap ,
88 isRecord ,
9- isRecordLike ,
9+ isRecordObject ,
1010 isSet ,
1111 type Primitive ,
1212} from "./core.ts" ;
@@ -368,17 +368,17 @@ export function isReadonlyUniformTupleOf<T, N extends number>(
368368}
369369
370370/**
371- * Return a type predicate function that returns `true` if the type of `x` is `Record<K, T>`.
371+ * Return a type predicate function that returns `true` if the type of `x` is an Object instance that satisfies `Record<K, T>`.
372372 *
373373 * To enhance performance, users are advised to cache the return value of this function and mitigate the creation cost.
374374 *
375375 * Note that this function check if the `x` is an instance of `Object`.
376- * Use `isRecordLikeOf ` instead if you want to check if the `x` satisfies the `Record<K, T>` type.
376+ * Use `isRecordOf ` instead if you want to check if the `x` satisfies the `Record<K, T>` type.
377377 *
378378 * ```ts
379379 * import { is } from "https://deno.land/x/unknownutil@$MODULE_VERSION/mod.ts";
380380 *
381- * const isMyType = is.RecordOf (is.Number);
381+ * const isMyType = is.RecordObjectOf (is.Number);
382382 * const a: unknown = {"a": 0, "b": 1};
383383 * if (isMyType(a)) {
384384 * // a is narrowed to Record<PropertyKey, number>
@@ -391,45 +391,45 @@ export function isReadonlyUniformTupleOf<T, N extends number>(
391391 * ```ts
392392 * import { is } from "https://deno.land/x/unknownutil@$MODULE_VERSION/mod.ts";
393393 *
394- * const isMyType = is.RecordOf (is.Number, is.String);
394+ * const isMyType = is.RecordObjectOf (is.Number, is.String);
395395 * const a: unknown = {"a": 0, "b": 1};
396396 * if (isMyType(a)) {
397397 * // a is narrowed to Record<string, number>
398398 * const _: Record<string, number> = a;
399399 * }
400400 * ```
401401 */
402- export function isRecordOf < T , K extends PropertyKey = PropertyKey > (
402+ export function isRecordObjectOf < T , K extends PropertyKey = PropertyKey > (
403403 pred : Predicate < T > ,
404404 predKey ?: Predicate < K > ,
405- ) : Predicate < Record < K , T > > & WithMetadata < IsRecordOfMetadata > {
405+ ) : Predicate < Record < K , T > > & WithMetadata < IsRecordObjectOfMetadata > {
406406 return setPredicateFactoryMetadata (
407407 ( x : unknown ) : x is Record < K , T > => {
408- if ( ! isRecord ( x ) ) return false ;
408+ if ( ! isRecordObject ( x ) ) return false ;
409409 for ( const k in x ) {
410410 if ( ! pred ( x [ k ] ) ) return false ;
411411 if ( predKey && ! predKey ( k ) ) return false ;
412412 }
413413 return true ;
414414 } ,
415- { name : "isRecordOf " , args : [ pred , predKey ] } ,
415+ { name : "isRecordObjectOf " , args : [ pred , predKey ] } ,
416416 ) ;
417417}
418418
419- type IsRecordOfMetadata = {
420- name : "isRecordOf " ;
421- args : Parameters < typeof isRecordOf > ;
419+ type IsRecordObjectOfMetadata = {
420+ name : "isRecordObjectOf " ;
421+ args : Parameters < typeof isRecordObjectOf > ;
422422} ;
423423
424424/**
425- * Return a type predicate function that returns `true` if the type of `x` is like `Record<K, T>`.
425+ * Return a type predicate function that returns `true` if the type of `x` satisfies `Record<K, T>`.
426426 *
427427 * To enhance performance, users are advised to cache the return value of this function and mitigate the creation cost.
428428 *
429429 * ```ts
430430 * import { is } from "https://deno.land/x/unknownutil@$MODULE_VERSION/mod.ts";
431431 *
432- * const isMyType = is.RecordLikeOf (is.Number);
432+ * const isMyType = is.RecordOf (is.Number);
433433 * const a: unknown = {"a": 0, "b": 1};
434434 * if (isMyType(a)) {
435435 * // a is narrowed to Record<PropertyKey, number>
@@ -450,23 +450,43 @@ type IsRecordOfMetadata = {
450450 * }
451451 * ```
452452 */
453- export function isRecordLikeOf < T , K extends PropertyKey = PropertyKey > (
453+ export function isRecordOf < T , K extends PropertyKey = PropertyKey > (
454454 pred : Predicate < T > ,
455455 predKey ?: Predicate < K > ,
456- ) : Predicate < Record < K , T > > & WithMetadata < IsRecordLikeOfMetadata > {
456+ ) : Predicate < Record < K , T > > & WithMetadata < IsRecordOfMetadata > {
457457 return setPredicateFactoryMetadata (
458458 ( x : unknown ) : x is Record < K , T > => {
459- if ( ! isRecordLike ( x ) ) return false ;
459+ if ( ! isRecord ( x ) ) return false ;
460460 for ( const k in x ) {
461461 if ( ! pred ( x [ k ] ) ) return false ;
462462 if ( predKey && ! predKey ( k ) ) return false ;
463463 }
464464 return true ;
465465 } ,
466- { name : "isRecordLikeOf " , args : [ pred , predKey ] } ,
466+ { name : "isRecordOf " , args : [ pred , predKey ] } ,
467467 ) ;
468468}
469469
470+ type IsRecordOfMetadata = {
471+ name : "isRecordOf" ;
472+ args : Parameters < typeof isRecordOf > ;
473+ } ;
474+
475+ /**
476+ * Return a type predicate function that returns `true` if the type of `x` satisfies `Record<K, T>`.
477+ *
478+ * @deprecated Use `is.RecordOf()` instead
479+ */
480+ export function isRecordLikeOf < T , K extends PropertyKey = PropertyKey > (
481+ pred : Predicate < T > ,
482+ predKey ?: Predicate < K > ,
483+ ) : Predicate < Record < K , T > > & WithMetadata < IsRecordLikeOfMetadata > {
484+ return setPredicateFactoryMetadata ( isRecordOf ( pred , predKey ) , {
485+ name : "isRecordLikeOf" ,
486+ args : [ pred , predKey ] ,
487+ } ) ;
488+ }
489+
470490type IsRecordLikeOfMetadata = {
471491 name : "isRecordLikeOf" ;
472492 args : Parameters < typeof isRecordLikeOf > ;
@@ -747,6 +767,7 @@ export default {
747767 ReadonlyTupleOf : isReadonlyTupleOf ,
748768 ReadonlyUniformTupleOf : isReadonlyUniformTupleOf ,
749769 RecordLikeOf : isRecordLikeOf ,
770+ RecordObjectOf : isRecordObjectOf ,
750771 RecordOf : isRecordOf ,
751772 SetOf : isSetOf ,
752773 StrictOf : isStrictOf ,
0 commit comments