MCPcopy
hub / github.com/jestjs/jest / asymmetricMatch

Method asymmetricMatch

packages/expect/src/asymmetricMatchers.ts:98–138  ·  view source on GitHub ↗
(other: unknown)

Source from the content-addressed store, hash-verified

96 }
97
98 asymmetricMatch(other: unknown) {
99 if (this.sample === String) {
100 // eslint-disable-next-line unicorn/no-instanceof-builtins
101 return typeof other === 'string' || other instanceof String;
102 }
103
104 if (this.sample === Number) {
105 // eslint-disable-next-line unicorn/no-instanceof-builtins
106 return typeof other === 'number' || other instanceof Number;
107 }
108
109 if (this.sample === Function) {
110 // eslint-disable-next-line unicorn/no-instanceof-builtins
111 return typeof other === 'function' || other instanceof Function;
112 }
113
114 if (this.sample === Boolean) {
115 // eslint-disable-next-line unicorn/no-instanceof-builtins
116 return typeof other === 'boolean' || other instanceof Boolean;
117 }
118
119 if (this.sample === BigInt) {
120 // eslint-disable-next-line unicorn/no-instanceof-builtins
121 return typeof other === 'bigint' || other instanceof BigInt;
122 }
123
124 if (this.sample === Symbol) {
125 // eslint-disable-next-line unicorn/no-instanceof-builtins
126 return typeof other === 'symbol' || other instanceof Symbol;
127 }
128
129 if (this.sample === Object) {
130 return typeof other === 'object';
131 }
132
133 if (this.sample === Array) {
134 return Array.isArray(other);
135 }
136
137 return other instanceof this.sample;
138 }
139
140 toString() {
141 return 'Any';

Callers 4

asymmetricMatchFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected