1 | const type = s =>
|
2 | Object.prototype.toString
|
3 | .call(s)
|
4 | .slice(8, -1)
|
5 | .toLowerCase();
|
6 |
|
7 | const types = [
|
8 | "String",
|
9 | "Array",
|
10 | "Undefined",
|
11 | "Boolean",
|
12 | "Number",
|
13 | "Function",
|
14 | "Symbol",
|
15 | "Object"
|
16 | ];
|
17 |
|
18 | module.exports = types.reduce((acc, str) => {
|
19 | acc["is" + str] = val => type(val) === str.toLowerCase();
|
20 | return acc;
|
21 | }, {});
|