@antv/util 2.0.15 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -241
- package/dist/util.min.js +1 -0
- package/esm/color/arr2rgb.d.ts +12 -0
- package/esm/color/arr2rgb.js +18 -0
- package/esm/color/arr2rgb.js.map +1 -0
- package/esm/color/gradient.d.ts +6 -0
- package/esm/color/gradient.js +45 -0
- package/esm/color/gradient.js.map +1 -0
- package/esm/color/index.d.ts +4 -0
- package/esm/color/index.js +6 -0
- package/esm/color/index.js.map +1 -0
- package/esm/color/rgb2arr.d.ts +6 -0
- package/esm/color/rgb2arr.js +9 -0
- package/esm/color/rgb2arr.js.map +1 -0
- package/esm/color/tocssgradient.d.ts +1 -0
- package/esm/color/tocssgradient.js +37 -0
- package/esm/color/tocssgradient.js.map +1 -0
- package/esm/color/torgb.d.ts +6 -0
- package/esm/color/torgb.js +36 -0
- package/esm/color/torgb.js.map +1 -0
- package/esm/helper/index.d.ts +2 -0
- package/esm/helper/index.js +3 -0
- package/esm/helper/index.js.map +1 -0
- package/esm/helper/mod.d.ts +1 -0
- package/esm/helper/mod.js +4 -0
- package/esm/helper/mod.js.map +1 -0
- package/esm/helper/to-radian.d.ts +1 -0
- package/esm/helper/to-radian.js +5 -0
- package/esm/helper/to-radian.js.map +1 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.js +4 -0
- package/esm/index.js.map +1 -0
- package/esm/matrix/index.d.ts +27 -0
- package/esm/matrix/index.js +97 -0
- package/esm/matrix/index.js.map +1 -0
- package/esm/path/catmull-rom-2-bezier.d.ts +10 -0
- package/esm/path/catmull-rom-2-bezier.js +115 -0
- package/esm/path/catmull-rom-2-bezier.js.map +1 -0
- package/esm/path/fill-path-by-diff.d.ts +5 -0
- package/esm/path/fill-path-by-diff.js +110 -0
- package/esm/path/fill-path-by-diff.js.map +1 -0
- package/esm/path/fill-path.d.ts +1 -0
- package/esm/path/fill-path.js +129 -0
- package/esm/path/fill-path.js.map +1 -0
- package/esm/path/format-path.d.ts +1 -0
- package/esm/path/format-path.js +139 -0
- package/esm/path/format-path.js.map +1 -0
- package/esm/path/get-arc-params.d.ts +17 -0
- package/esm/path/get-arc-params.js +90 -0
- package/esm/path/get-arc-params.js.map +1 -0
- package/esm/path/get-line-intersect.d.ts +14 -0
- package/esm/path/get-line-intersect.js +33 -0
- package/esm/path/get-line-intersect.js.map +1 -0
- package/esm/path/index.d.ts +16 -0
- package/esm/path/index.js +17 -0
- package/esm/path/index.js.map +1 -0
- package/esm/path/is-polygons-intersect.d.ts +1 -0
- package/esm/path/is-polygons-intersect.js +81 -0
- package/esm/path/is-polygons-intersect.js.map +1 -0
- package/esm/path/parse-path-array.d.ts +1 -0
- package/esm/path/parse-path-array.js +5 -0
- package/esm/path/parse-path-array.js.map +1 -0
- package/esm/path/parse-path-string.d.ts +1 -0
- package/esm/path/parse-path-string.js +57 -0
- package/esm/path/parse-path-string.js.map +1 -0
- package/esm/path/parse-path.d.ts +1 -0
- package/esm/path/parse-path.js +33 -0
- package/esm/path/parse-path.js.map +1 -0
- package/esm/path/path-2-absolute.d.ts +1 -0
- package/esm/path/path-2-absolute.js +124 -0
- package/esm/path/path-2-absolute.js.map +1 -0
- package/esm/path/path-2-curve.d.ts +2 -0
- package/esm/path/path-2-curve.js +63 -0
- package/esm/path/path-2-curve.js.map +1 -0
- package/esm/path/path-2-segments.d.ts +1 -0
- package/esm/path/path-2-segments.js +138 -0
- package/esm/path/path-2-segments.js.map +1 -0
- package/esm/path/path-intersection.d.ts +9 -0
- package/esm/path/path-intersection.js +366 -0
- package/esm/path/path-intersection.js.map +1 -0
- package/esm/path/point-in-polygon.d.ts +5 -0
- package/esm/path/point-in-polygon.js +49 -0
- package/esm/path/point-in-polygon.js.map +1 -0
- package/esm/path/process/arc-2-cubic.d.ts +1 -0
- package/esm/path/process/arc-2-cubic.js +140 -0
- package/esm/path/process/arc-2-cubic.js.map +1 -0
- package/esm/path/process/line-2-cubic.d.ts +1 -0
- package/esm/path/process/line-2-cubic.js +35 -0
- package/esm/path/process/line-2-cubic.js.map +1 -0
- package/esm/path/process/quad-2-cubic.d.ts +1 -0
- package/esm/path/process/quad-2-cubic.js +13 -0
- package/esm/path/process/quad-2-cubic.js.map +1 -0
- package/esm/path/process/segment-2-cubic.d.ts +2 -0
- package/esm/path/process/segment-2-cubic.js +37 -0
- package/esm/path/process/segment-2-cubic.js.map +1 -0
- package/esm/path/rect-path.d.ts +4 -0
- package/esm/path/rect-path.js +19 -0
- package/esm/path/rect-path.js.map +1 -0
- package/esm/path/types.d.ts +25 -0
- package/esm/path/types.js +2 -0
- package/esm/path/types.js.map +1 -0
- package/lib/color/arr2rgb.d.ts +12 -0
- package/lib/color/arr2rgb.js +23 -0
- package/lib/color/arr2rgb.js.map +1 -0
- package/lib/color/gradient.d.ts +6 -0
- package/lib/color/gradient.js +49 -0
- package/lib/color/gradient.js.map +1 -0
- package/lib/color/index.d.ts +4 -0
- package/lib/color/index.js +13 -0
- package/lib/color/index.js.map +1 -0
- package/lib/color/rgb2arr.d.ts +6 -0
- package/lib/color/rgb2arr.js +13 -0
- package/lib/color/rgb2arr.js.map +1 -0
- package/lib/color/tocssgradient.d.ts +1 -0
- package/lib/color/tocssgradient.js +41 -0
- package/lib/color/tocssgradient.js.map +1 -0
- package/lib/color/torgb.d.ts +6 -0
- package/lib/color/torgb.js +40 -0
- package/lib/color/torgb.js.map +1 -0
- package/lib/helper/index.d.ts +2 -0
- package/lib/helper/index.js +8 -0
- package/lib/helper/index.js.map +1 -0
- package/lib/helper/mod.d.ts +1 -0
- package/lib/helper/mod.js +8 -0
- package/lib/helper/mod.js.map +1 -0
- package/lib/helper/to-radian.d.ts +1 -0
- package/lib/helper/to-radian.js +9 -0
- package/lib/helper/to-radian.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +16 -0
- package/lib/index.js.map +1 -0
- package/lib/matrix/index.d.ts +27 -0
- package/lib/matrix/index.js +104 -0
- package/lib/matrix/index.js.map +1 -0
- package/lib/path/catmull-rom-2-bezier.d.ts +10 -0
- package/lib/path/catmull-rom-2-bezier.js +119 -0
- package/lib/path/catmull-rom-2-bezier.js.map +1 -0
- package/lib/path/fill-path-by-diff.d.ts +5 -0
- package/lib/path/fill-path-by-diff.js +117 -0
- package/lib/path/fill-path-by-diff.js.map +1 -0
- package/lib/path/fill-path.d.ts +1 -0
- package/lib/path/fill-path.js +133 -0
- package/lib/path/fill-path.js.map +1 -0
- package/lib/path/format-path.d.ts +1 -0
- package/lib/path/format-path.js +143 -0
- package/lib/path/format-path.js.map +1 -0
- package/lib/path/get-arc-params.d.ts +17 -0
- package/lib/path/get-arc-params.js +95 -0
- package/lib/path/get-arc-params.js.map +1 -0
- package/lib/path/get-line-intersect.d.ts +14 -0
- package/lib/path/get-line-intersect.js +37 -0
- package/lib/path/get-line-intersect.js.map +1 -0
- package/lib/path/index.d.ts +16 -0
- package/lib/path/index.js +36 -0
- package/lib/path/index.js.map +1 -0
- package/lib/path/is-polygons-intersect.d.ts +1 -0
- package/lib/path/is-polygons-intersect.js +85 -0
- package/lib/path/is-polygons-intersect.js.map +1 -0
- package/lib/path/parse-path-array.d.ts +1 -0
- package/lib/path/parse-path-array.js +9 -0
- package/lib/path/parse-path-array.js.map +1 -0
- package/lib/path/parse-path-string.d.ts +1 -0
- package/lib/path/parse-path-string.js +61 -0
- package/lib/path/parse-path-string.js.map +1 -0
- package/lib/path/parse-path.d.ts +1 -0
- package/lib/path/parse-path.js +37 -0
- package/lib/path/parse-path.js.map +1 -0
- package/lib/path/path-2-absolute.d.ts +1 -0
- package/lib/path/path-2-absolute.js +128 -0
- package/lib/path/path-2-absolute.js.map +1 -0
- package/lib/path/path-2-curve.d.ts +2 -0
- package/lib/path/path-2-curve.js +67 -0
- package/lib/path/path-2-curve.js.map +1 -0
- package/lib/path/path-2-segments.d.ts +1 -0
- package/lib/path/path-2-segments.js +142 -0
- package/lib/path/path-2-segments.js.map +1 -0
- package/lib/path/path-intersection.d.ts +9 -0
- package/lib/path/path-intersection.js +370 -0
- package/lib/path/path-intersection.js.map +1 -0
- package/lib/path/point-in-polygon.d.ts +5 -0
- package/lib/path/point-in-polygon.js +53 -0
- package/lib/path/point-in-polygon.js.map +1 -0
- package/lib/path/process/arc-2-cubic.d.ts +1 -0
- package/lib/path/process/arc-2-cubic.js +144 -0
- package/lib/path/process/arc-2-cubic.js.map +1 -0
- package/lib/path/process/line-2-cubic.d.ts +1 -0
- package/lib/path/process/line-2-cubic.js +39 -0
- package/lib/path/process/line-2-cubic.js.map +1 -0
- package/lib/path/process/quad-2-cubic.d.ts +1 -0
- package/lib/path/process/quad-2-cubic.js +17 -0
- package/lib/path/process/quad-2-cubic.js.map +1 -0
- package/lib/path/process/segment-2-cubic.d.ts +2 -0
- package/lib/path/process/segment-2-cubic.js +41 -0
- package/lib/path/process/segment-2-cubic.js.map +1 -0
- package/lib/path/rect-path.d.ts +4 -0
- package/lib/path/rect-path.js +23 -0
- package/lib/path/rect-path.js.map +1 -0
- package/lib/path/types.d.ts +25 -0
- package/lib/path/types.js +3 -0
- package/lib/path/types.js.map +1 -0
- package/package.json +77 -36
- package/src/color/arr2rgb.ts +19 -0
- package/src/color/gradient.ts +55 -0
- package/src/color/index.ts +5 -0
- package/src/color/rgb2arr.ts +8 -0
- package/src/color/tocssgradient.ts +43 -0
- package/src/color/torgb.ts +45 -0
- package/src/helper/index.ts +2 -0
- package/src/helper/mod.ts +3 -0
- package/src/helper/to-radian.ts +5 -0
- package/src/index.ts +3 -130
- package/src/matrix/index.ts +108 -0
- package/src/path/catmull-rom-2-bezier.ts +141 -0
- package/src/path/fill-path-by-diff.ts +116 -0
- package/src/path/fill-path.ts +129 -0
- package/src/path/format-path.ts +142 -0
- package/src/path/get-arc-params.ts +102 -0
- package/src/path/get-line-intersect.ts +46 -0
- package/src/path/index.ts +16 -0
- package/src/path/is-polygons-intersect.ts +95 -0
- package/src/path/parse-path-array.ts +5 -0
- package/src/path/parse-path-string.ts +63 -0
- package/src/path/parse-path.ts +34 -0
- package/src/path/path-2-absolute.ts +132 -0
- package/src/path/path-2-curve.ts +69 -0
- package/src/path/path-2-segments.ts +142 -0
- package/src/path/path-intersection.ts +419 -0
- package/src/path/point-in-polygon.ts +56 -0
- package/src/path/process/arc-2-cubic.ts +221 -0
- package/src/path/process/line-2-cubic.ts +37 -0
- package/src/path/process/quad-2-cubic.ts +12 -0
- package/src/path/process/segment-2-cubic.ts +44 -0
- package/src/path/rect-path.ts +22 -0
- package/src/path/types.ts +25 -0
- package/src/augment.ts +0 -16
- package/src/cache.ts +0 -31
- package/src/clamp.ts +0 -10
- package/src/clear-animation-frame.ts +0 -11
- package/src/clone.ts +0 -31
- package/src/contains.ts +0 -10
- package/src/debounce.ts +0 -22
- package/src/deep-mix.ts +0 -39
- package/src/difference.ts +0 -17
- package/src/each.ts +0 -28
- package/src/ends-with.ts +0 -10
- package/src/every.ts +0 -14
- package/src/extend.ts +0 -36
- package/src/filter.ts +0 -18
- package/src/find-index.ts +0 -12
- package/src/find.ts +0 -29
- package/src/first-value.ts +0 -21
- package/src/fixed-base.ts +0 -14
- package/src/flatten-deep.ts +0 -24
- package/src/flatten.ts +0 -23
- package/src/for-in.ts +0 -3
- package/src/get-ellipsis-text.ts +0 -75
- package/src/get-range.ts +0 -35
- package/src/get-type.ts +0 -7
- package/src/get-wrap-behavior.ts +0 -13
- package/src/get.ts +0 -18
- package/src/group-by.ts +0 -35
- package/src/group-to-map.ts +0 -30
- package/src/group.ts +0 -14
- package/src/has-key.ts +0 -2
- package/src/has-value.ts +0 -4
- package/src/has.ts +0 -1
- package/src/head.ts +0 -8
- package/src/identity.ts +0 -1
- package/src/index-of.ts +0 -22
- package/src/is-arguments.ts +0 -13
- package/src/is-array-like.ts +0 -11
- package/src/is-array.ts +0 -7
- package/src/is-boolean.ts +0 -13
- package/src/is-date.ts +0 -7
- package/src/is-decimal.ts +0 -7
- package/src/is-element.ts +0 -8
- package/src/is-empty.ts +0 -39
- package/src/is-equal-with.ts +0 -31
- package/src/is-equal.ts +0 -46
- package/src/is-error.ts +0 -13
- package/src/is-even.ts +0 -7
- package/src/is-finite.ts +0 -11
- package/src/is-function.ts +0 -10
- package/src/is-integer.ts +0 -7
- package/src/is-match.ts +0 -17
- package/src/is-negative.ts +0 -7
- package/src/is-nil.ts +0 -10
- package/src/is-null.ts +0 -5
- package/src/is-number-equal.ts +0 -5
- package/src/is-number.ts +0 -10
- package/src/is-object-like.ts +0 -11
- package/src/is-object.ts +0 -10
- package/src/is-odd.ts +0 -7
- package/src/is-plain-object.ts +0 -24
- package/src/is-positive.ts +0 -7
- package/src/is-prototype.ts +0 -9
- package/src/is-reg-exp.ts +0 -7
- package/src/is-segment-equal.ts +0 -15
- package/src/is-string.ts +0 -5
- package/src/is-type.ts +0 -5
- package/src/is-undefined.ts +0 -5
- package/src/keys.ts +0 -14
- package/src/last.ts +0 -9
- package/src/lower-case.ts +0 -7
- package/src/lower-first.ts +0 -8
- package/src/map-values.ts +0 -19
- package/src/map.ts +0 -17
- package/src/max-by.ts +0 -37
- package/src/max.ts +0 -28
- package/src/measure-text-width.ts +0 -25
- package/src/memoize.ts +0 -31
- package/src/merge.ts +0 -12
- package/src/min-by.ts +0 -38
- package/src/min.ts +0 -28
- package/src/mix.ts +0 -15
- package/src/mod.ts +0 -5
- package/src/noop.ts +0 -1
- package/src/number2color.ts +0 -17
- package/src/omit.ts +0 -15
- package/src/parse-radius.ts +0 -45
- package/src/pick.ts +0 -32
- package/src/pull-at.ts +0 -23
- package/src/pull.ts +0 -16
- package/src/reduce.ts +0 -17
- package/src/remove.ts +0 -30
- package/src/request-animation-frame.ts +0 -13
- package/src/set.ts +0 -29
- package/src/size.ts +0 -12
- package/src/some.ts +0 -14
- package/src/sort-by.ts +0 -42
- package/src/starts-with.ts +0 -10
- package/src/substitute.ts +0 -17
- package/src/throttle.ts +0 -48
- package/src/to-array.ts +0 -5
- package/src/to-degree.ts +0 -7
- package/src/to-integer.ts +0 -1
- package/src/to-radian.ts +0 -7
- package/src/to-string.ts +0 -6
- package/src/types/index.ts +0 -3
- package/src/union.ts +0 -7
- package/src/uniq.ts +0 -15
- package/src/unique-id.ts +0 -11
- package/src/upper-case.ts +0 -7
- package/src/upper-first.ts +0 -8
- package/src/values-of-key.ts +0 -29
- package/src/values.ts +0 -15
- package/src/wrap-behavior.ts +0 -20
package/src/get-range.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import isArray from './is-array';
|
|
2
|
-
import { default as getMax } from './max';
|
|
3
|
-
import { default as getMin } from './min';
|
|
4
|
-
|
|
5
|
-
export interface RangeType {
|
|
6
|
-
readonly min: number;
|
|
7
|
-
readonly max: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const getRange = function (values: number[]): RangeType {
|
|
11
|
-
// 存在 NaN 时,min,max 判定会出问题
|
|
12
|
-
let filterValues = values.filter((v) => !isNaN(v));
|
|
13
|
-
if (!filterValues.length) {
|
|
14
|
-
// 如果没有数值则直接返回0
|
|
15
|
-
return {
|
|
16
|
-
min: 0,
|
|
17
|
-
max: 0,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
if (isArray(values[0])) {
|
|
21
|
-
let tmp = [];
|
|
22
|
-
for (let i = 0; i < values.length; i++) {
|
|
23
|
-
tmp = tmp.concat(values[i]);
|
|
24
|
-
}
|
|
25
|
-
filterValues = tmp;
|
|
26
|
-
}
|
|
27
|
-
const max = getMax(filterValues);
|
|
28
|
-
const min = getMin(filterValues);
|
|
29
|
-
return {
|
|
30
|
-
min,
|
|
31
|
-
max,
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default getRange;
|
package/src/get-type.ts
DELETED
package/src/get-wrap-behavior.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* 获取封装的事件
|
|
4
|
-
* @protected
|
|
5
|
-
* @param {Object} obj 对象
|
|
6
|
-
* @param {String} action 事件名称
|
|
7
|
-
* @return {Function} 返回事件处理函数
|
|
8
|
-
*/
|
|
9
|
-
function getWrapBehavior(obj: object, action: string): Function {
|
|
10
|
-
return obj['_wrap_' + action];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default getWrapBehavior;
|
package/src/get.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import isString from './is-string';
|
|
2
|
-
/**
|
|
3
|
-
* https://github.com/developit/dlv/blob/master/index.js
|
|
4
|
-
* @param obj
|
|
5
|
-
* @param key
|
|
6
|
-
* @param defaultValue
|
|
7
|
-
*/
|
|
8
|
-
export default (obj: any, key: string | any[], defaultValue?: any): any => {
|
|
9
|
-
let p = 0;
|
|
10
|
-
|
|
11
|
-
const keyArr = isString(key) ? key.split('.') : key;
|
|
12
|
-
|
|
13
|
-
while (obj && p < keyArr.length) {
|
|
14
|
-
obj = obj[keyArr[p++]];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return (obj === undefined || p < keyArr.length) ? defaultValue : obj;
|
|
18
|
-
}
|
package/src/group-by.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import isArray from './is-array';
|
|
2
|
-
import isFunction from './is-function';
|
|
3
|
-
|
|
4
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
6
|
-
export interface ObjectType<T> {
|
|
7
|
-
[key: string]: T[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function groupBy<T>(data: T[], condition: (item: T) => string): ObjectType<T>;
|
|
11
|
-
function groupBy<T>(data: T[], condition: string): ObjectType<T>;
|
|
12
|
-
function groupBy<T>(data: T[], condition: ((item: T) => string) | string): ObjectType<T> {
|
|
13
|
-
if (!condition || !isArray(data)) {
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
const result: ObjectType<T> = {};
|
|
17
|
-
|
|
18
|
-
// 兼容方法和 字符串的写法
|
|
19
|
-
const predicate = isFunction(condition) ? condition : (item) => item[condition];
|
|
20
|
-
|
|
21
|
-
let key: string;
|
|
22
|
-
for (let i = 0; i < data.length; i++) {
|
|
23
|
-
const item = data[i];
|
|
24
|
-
key = predicate(item);
|
|
25
|
-
if (hasOwnProperty.call(result, key)) {
|
|
26
|
-
result[key].push(item);
|
|
27
|
-
} else {
|
|
28
|
-
result[key] = [ item ];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default groupBy;
|
package/src/group-to-map.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import isArray from './is-array';
|
|
2
|
-
import isFunction from './is-function';
|
|
3
|
-
import groupBy from './group-by';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 将数据分组成 map
|
|
7
|
-
* @param data
|
|
8
|
-
* @param condition
|
|
9
|
-
*/
|
|
10
|
-
export default function groupToMap(data: any, condition: string[] | string | ((row: any) => string)) {
|
|
11
|
-
if (!condition) {
|
|
12
|
-
return {
|
|
13
|
-
0: data,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
if (!isFunction(condition)) {
|
|
17
|
-
// 如果是字符串,则按照 a*b 风格成数组
|
|
18
|
-
const paramscondition = isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*');
|
|
19
|
-
condition = function (row) {
|
|
20
|
-
let unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序
|
|
21
|
-
|
|
22
|
-
// 根据字段列表的值,拼接成 key
|
|
23
|
-
for (let i = 0, l = paramscondition.length; i < l; i++) {
|
|
24
|
-
unique += row[paramscondition[i]] && row[paramscondition[i]].toString();
|
|
25
|
-
}
|
|
26
|
-
return unique;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return groupBy(data, condition);
|
|
30
|
-
}
|
package/src/group.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import groupToMap from './group-to-map';
|
|
2
|
-
|
|
3
|
-
export default <T>(data: T[], condition: ((v: T) => string) | string | string[]): T[][] => {
|
|
4
|
-
if (!condition) {
|
|
5
|
-
// 没有条件,则自身改成数组
|
|
6
|
-
return [ data ];
|
|
7
|
-
}
|
|
8
|
-
const groups = groupToMap(data, condition) as { [key: string]: T };
|
|
9
|
-
const array = [];
|
|
10
|
-
for (const i in groups) {
|
|
11
|
-
array.push(groups[i]);
|
|
12
|
-
}
|
|
13
|
-
return array;
|
|
14
|
-
};
|
package/src/has-key.ts
DELETED
package/src/has-value.ts
DELETED
package/src/has.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default (obj: object, key: any): boolean => obj.hasOwnProperty(key);
|
package/src/head.ts
DELETED
package/src/identity.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default <T>(v: T): T => v;
|
package/src/index-of.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isArrayLike from './is-array-like';
|
|
2
|
-
|
|
3
|
-
const indexOf = function<T> (arr: T[], obj: T): number {
|
|
4
|
-
if (!isArrayLike(arr)) {
|
|
5
|
-
return -1;
|
|
6
|
-
}
|
|
7
|
-
const m = Array.prototype.indexOf;
|
|
8
|
-
if (m) {
|
|
9
|
-
return m.call(arr, obj);
|
|
10
|
-
}
|
|
11
|
-
let index = -1;
|
|
12
|
-
|
|
13
|
-
for (let i = 0; i < arr.length; i++) {
|
|
14
|
-
if (arr[i] === obj) {
|
|
15
|
-
index = i;
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return index;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default indexOf;
|
package/src/is-arguments.ts
DELETED
package/src/is-array-like.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const isArrayLike = function(value: any): boolean {
|
|
2
|
-
/**
|
|
3
|
-
* isArrayLike([1, 2, 3]) => true
|
|
4
|
-
* isArrayLike(document.body.children) => true
|
|
5
|
-
* isArrayLike('abc') => true
|
|
6
|
-
* isArrayLike(Function) => false
|
|
7
|
-
*/
|
|
8
|
-
return value !== null && typeof value !== 'function' && isFinite(value.length);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default isArrayLike;
|
package/src/is-array.ts
DELETED
package/src/is-boolean.ts
DELETED
package/src/is-date.ts
DELETED
package/src/is-decimal.ts
DELETED
package/src/is-element.ts
DELETED
package/src/is-empty.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import isNil from './is-nil';
|
|
2
|
-
import isArrayLike from './is-array-like';
|
|
3
|
-
import getType from './get-type';
|
|
4
|
-
import isPrototype from './is-prototype';
|
|
5
|
-
|
|
6
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
7
|
-
|
|
8
|
-
function isEmpty(value: any): boolean {
|
|
9
|
-
/**
|
|
10
|
-
* isEmpty(null) => true
|
|
11
|
-
* isEmpty() => true
|
|
12
|
-
* isEmpty(true) => true
|
|
13
|
-
* isEmpty(1) => true
|
|
14
|
-
* isEmpty([1, 2, 3]) => false
|
|
15
|
-
* isEmpty('abc') => false
|
|
16
|
-
* isEmpty({ a: 1 }) => false
|
|
17
|
-
*/
|
|
18
|
-
if (isNil(value)) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
if (isArrayLike(value)) {
|
|
22
|
-
return !value.length;
|
|
23
|
-
}
|
|
24
|
-
const type = getType(value);
|
|
25
|
-
if (type === 'Map' || type === 'Set') {
|
|
26
|
-
return !value.size;
|
|
27
|
-
}
|
|
28
|
-
if (isPrototype(value)) {
|
|
29
|
-
return !Object.keys(value).length;
|
|
30
|
-
}
|
|
31
|
-
for (const key in value) {
|
|
32
|
-
if (hasOwnProperty.call(value, key)) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default isEmpty;
|
package/src/is-equal-with.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import isFunction from './is-function';
|
|
2
|
-
import isEqual from './is-equal';
|
|
3
|
-
/**
|
|
4
|
-
* @param {*} value The value to compare.
|
|
5
|
-
* @param {*} other The other value to compare.
|
|
6
|
-
* @param {Function} [fn] The function to customize comparisons.
|
|
7
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
8
|
-
* @example
|
|
9
|
-
*
|
|
10
|
-
* function isGreeting(value) {
|
|
11
|
-
* return /^h(?:i|ello)$/.test(value);
|
|
12
|
-
* }
|
|
13
|
-
*
|
|
14
|
-
* function customizer(objValue, othValue) {
|
|
15
|
-
* if (isGreeting(objValue) && isGreeting(othValue)) {
|
|
16
|
-
* return true;
|
|
17
|
-
* }
|
|
18
|
-
* }
|
|
19
|
-
*
|
|
20
|
-
* var array = ['hello', 'goodbye'];
|
|
21
|
-
* var other = ['hi', 'goodbye'];
|
|
22
|
-
*
|
|
23
|
-
* isEqualWith(array, other, customizer); // => true
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
export default <T>(value: T, other: T, fn: (v1: T, v2: T) => boolean): boolean => {
|
|
27
|
-
if (!isFunction(fn)) {
|
|
28
|
-
return isEqual(value, other);
|
|
29
|
-
}
|
|
30
|
-
return !!fn(value, other);
|
|
31
|
-
};
|
package/src/is-equal.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import isObjectLike from './is-object-like';
|
|
2
|
-
import isArrayLike from './is-array-like';
|
|
3
|
-
import isString from './is-string';
|
|
4
|
-
|
|
5
|
-
const isEqual = (value: any, other: any): boolean => {
|
|
6
|
-
if (value === other) {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
if (!value || !other) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
if (isString(value) || isString(other)) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
if (isArrayLike(value) || isArrayLike(other)) {
|
|
16
|
-
if (value.length !== other.length) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
let rst = true;
|
|
20
|
-
for (let i = 0; i < value.length; i++) {
|
|
21
|
-
rst = isEqual(value[i], other[i]);
|
|
22
|
-
if (!rst) {
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return rst;
|
|
27
|
-
}
|
|
28
|
-
if (isObjectLike(value) || isObjectLike(other)) {
|
|
29
|
-
const valueKeys = Object.keys(value);
|
|
30
|
-
const otherKeys = Object.keys(other);
|
|
31
|
-
if (valueKeys.length !== otherKeys.length) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
let rst = true;
|
|
35
|
-
for (let i = 0; i < valueKeys.length; i++) {
|
|
36
|
-
rst = isEqual(value[valueKeys[i]], other[valueKeys[i]]);
|
|
37
|
-
if (!rst) {
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return rst;
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default isEqual;
|
package/src/is-error.ts
DELETED
package/src/is-even.ts
DELETED
package/src/is-finite.ts
DELETED
package/src/is-function.ts
DELETED
package/src/is-integer.ts
DELETED
package/src/is-match.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import isNil from './is-nil';
|
|
2
|
-
import keys from './keys';
|
|
3
|
-
|
|
4
|
-
function isMatch(obj: any, attrs: any): boolean {
|
|
5
|
-
const _keys = keys(attrs);
|
|
6
|
-
const length = _keys.length;
|
|
7
|
-
if (isNil(obj)) return !length;
|
|
8
|
-
for (let i = 0; i < length; i += 1) {
|
|
9
|
-
const key = _keys[i];
|
|
10
|
-
if (attrs[key] !== obj[key] || !(key in obj)) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default isMatch;
|
package/src/is-negative.ts
DELETED
package/src/is-nil.ts
DELETED
package/src/is-null.ts
DELETED
package/src/is-number-equal.ts
DELETED
package/src/is-number.ts
DELETED
package/src/is-object-like.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const isObjectLike = function(value: any): value is object {
|
|
2
|
-
/**
|
|
3
|
-
* isObjectLike({}) => true
|
|
4
|
-
* isObjectLike([1, 2, 3]) => true
|
|
5
|
-
* isObjectLike(Function) => false
|
|
6
|
-
* isObjectLike(null) => false
|
|
7
|
-
*/
|
|
8
|
-
return typeof value === 'object' && value !== null;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default isObjectLike;
|
package/src/is-object.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default <T = object>(value: any): value is T => {
|
|
2
|
-
/**
|
|
3
|
-
* isObject({}) => true
|
|
4
|
-
* isObject([1, 2, 3]) => true
|
|
5
|
-
* isObject(Function) => true
|
|
6
|
-
* isObject(null) => false
|
|
7
|
-
*/
|
|
8
|
-
const type = typeof value;
|
|
9
|
-
return value !== null && type === 'object' || type === 'function';
|
|
10
|
-
};
|
package/src/is-odd.ts
DELETED
package/src/is-plain-object.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import isObjectLike from './is-object-like';
|
|
2
|
-
import isType from './is-type';
|
|
3
|
-
|
|
4
|
-
const isPlainObject = function(value: any): value is object {
|
|
5
|
-
/**
|
|
6
|
-
* isObjectLike(new Foo) => false
|
|
7
|
-
* isObjectLike([1, 2, 3]) => false
|
|
8
|
-
* isObjectLike({ x: 0, y: 0 }) => true
|
|
9
|
-
* isObjectLike(Object.create(null)) => true
|
|
10
|
-
*/
|
|
11
|
-
if (!isObjectLike(value) || !isType(value, 'Object')) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (Object.getPrototypeOf(value) === null) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
let proto = value;
|
|
18
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
19
|
-
proto = Object.getPrototypeOf(proto);
|
|
20
|
-
}
|
|
21
|
-
return Object.getPrototypeOf(value) === proto;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default isPlainObject;
|
package/src/is-positive.ts
DELETED
package/src/is-prototype.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const objectProto = Object.prototype;
|
|
2
|
-
|
|
3
|
-
const isPrototype = function(value: any): boolean {
|
|
4
|
-
const Ctor = value && value.constructor;
|
|
5
|
-
const proto = (typeof Ctor === 'function' && Ctor.prototype) || objectProto;
|
|
6
|
-
return value === proto;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default isPrototype;
|
package/src/is-reg-exp.ts
DELETED
package/src/is-segment-equal.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import each from './each';
|
|
2
|
-
|
|
3
|
-
export default (obj1: any, obj2: any): boolean => {
|
|
4
|
-
if (obj1.length !== obj2.length) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
let result = true;
|
|
8
|
-
each(obj1, (item, i) => {
|
|
9
|
-
if (item !== obj2[i]) {
|
|
10
|
-
result = false;
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
return result;
|
|
15
|
-
};
|
package/src/is-string.ts
DELETED
package/src/is-type.ts
DELETED