forked from ninecat-ui/ninecat-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.ts
More file actions
70 lines (61 loc) · 2.31 KB
/
Copy pathutil.ts
File metadata and controls
70 lines (61 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
export const isFunction = val => typeof val === 'function';
export const isArray = Array.isArray;
export const isString = val => typeof val === 'string';
export const isSymbol = val => typeof val === 'symbol';
export const isObject = val => val !== null && typeof val === 'object';
// const onRE = /^on[^a-z]/;
// const isOn = key => onRE.test(key);
// const cacheStringFunction = fn => {
// const cache = Object.create(null);
// return str => {
// const hit = cache[str];
// return hit || (cache[str] = fn(str));
// };
// };
// const camelizeRE = /-(\w)/g;
// const camelize = cacheStringFunction(str => {
// return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
// });
// const hyphenateRE = /\B([A-Z])/g;
// const hyphenate = cacheStringFunction(str => {
// return str.replace(hyphenateRE, '-$1').toLowerCase();
// });
// const capitalize = cacheStringFunction(str => {
// return str.charAt(0).toUpperCase() + str.slice(1);
// });
// const hasOwnProperty = Object.prototype.hasOwnProperty;
// const hasOwn = (val, key) => hasOwnProperty.call(val, key);
// // change from vue sourcecode
// function resolvePropValue (options, props, key, value) {
// const opt = options[key];
// if (opt != null) {
// const hasDefault = hasOwn(opt, 'default');
// // default values
// if (hasDefault && value === undefined) {
// const defaultValue = opt.default;
// value = opt.type !== Function && isFunction(defaultValue) ? defaultValue() : defaultValue;
// }
// // boolean casting
// if (opt[0 /* shouldCast */]) {
// if (!hasOwn(props, key) && !hasDefault) {
// value = false;
// } else if (opt[1 /* shouldCastTrue */] && (value === '' || value === hyphenate(key))) {
// value = true;
// }
// }
// }
// return value;
// }
// export function getDataAndAriaProps (props) {
// return Object.keys(props).reduce((memo, key) => {
// if (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-') {
// memo[key] = props[key];
// }
// return memo;
// }, {});
// }
export const guid = () => {
const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
return `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4() + s4() + s4()}`;
};
// export { isOn, cacheStringFunction, camelize, hyphenate, capitalize };