1 | 'use strict';
|
2 | import LodashIsEqual from 'lodash.isequal';
|
3 | import LodashIsPlainObject from 'lodash.isplainobject';
|
4 |
|
5 | export const assert = (condition, message) => {
|
6 |
|
7 | if (condition)
|
8 | return condition;
|
9 |
|
10 | throw new Error(message);
|
11 | };
|
12 |
|
13 | export const isDeeplyEqual = LodashIsEqual;
|
14 | export const isEqualTo = (value, input) => input === value;
|
15 | export const isTrue = input => isEqualTo(true, input);
|
16 | export const isUndefined = input => isEqualTo(void 0, input);
|
17 | export const isNull = input => isEqualTo(null, input);
|
18 | export const isInstanceOf = (type, input) => input instanceof type;
|
19 | export const isArray = input => isInstanceOf(Array, input);
|
20 | export const ofType = (type, input) => isEqualTo(type, typeof input);
|
21 | export const isObject = input => ofType('object', input);
|
22 | export const isPlainObject = LodashIsPlainObject;
|
23 | export const isEmpty = input => input.length < 1;
|
24 | export const isBoolean = input => ofType('boolean', input);
|
25 | export const isString = input => {
|
26 |
|
27 | return ofType('string', input);
|
28 | };
|
29 | export const isFunction = input => ofType('function', input) && input;
|
30 | export const isNumber = input => ofType('number', input);
|
31 | export const isInteger = input => Number.isInteger(input);
|
32 | export const isComponent = input => isObject(input) && input.isPwetComponent === true;
|
33 | export const isElement = input => isInstanceOf(HTMLElement, input);
|
34 | export const isUnknownElement = input => Object.prototype.toString.call(input) === '[object HTMLUnknownElement]'; |
\ | No newline at end of file |