blob: 2d20eec75784af1ea74234f6c36c7db820092aea (
plain)
1
2
3
4
5
6
7
8
9
10
|
// There is a problem with using boxed numbers and strings in TS,
// so we cannot just use `instanceof` here
const constructors = ['Number', 'String'];
export default function isBoxedPrimitive(o: any): o is Number | String {
return (
constructors.includes(o.constructor.name) &&
typeof o?.valueOf() !== 'object'
);
}
|