@antv/util

  • Version 2.0.14
  • Published
  • 335 kB
  • 1 dependency
  • ISC license

Install

npm i @antv/util
yarn add @antv/util
pnpm add @antv/util

Overview

A common util collection for antv projects

Index

Functions

function assign

assign: <Base, A, B, C>(
dist: Base & A & B & C,
src1?: A,
src2?: B,
src3?: C
) => Base & A & B & C;

    function augment

    augment: (...args: any[]) => void;

      function clamp

      clamp: (a: number, min: number, max: number) => number;

        function clearAnimationFrame

        clearAnimationFrame: (handler: number) => void;

          function clone

          clone: (obj: any) => any;

            function contains

            contains: (arr: any[], value: any) => boolean;

              function debounce

              debounce: (func: Function, wait?: number, immediate?: boolean) => () => void;

                function deepMix

                deepMix: (rst: any, ...args: any[]) => any;

                  function difference

                  difference: <T>(arr: T[], values?: T[]) => T[];
                  • Flattens array a single level deep.

                    Parameter arr

                    The array to inspect.

                    Parameter values

                    The values to exclude. {Array} Returns the new array of filtered values.

                    Example 1

                    difference([2, 1], [2, 3]); // => [1]

                  function each

                  each: (elements: any[] | object, func: (v: any, k: any) => any) => void;

                    function endsWith

                    endsWith: { (arr: string, e: string): boolean; <T>(arr: T[], e: T): boolean };

                      function every

                      every: <T>(arr: T[], func: (v: T, idx?: number) => any) => boolean;
                      • 只要有一个不满足条件就返回 false

                        Parameter arr

                        Parameter func

                      function extend

                      extend: (
                      subclass: any,
                      superclass: any,
                      overrides?: any,
                      staticOverrides?: any
                      ) => any;

                        function filter

                        filter: <T>(arr: T[], func: (v: T, idx: number) => boolean) => T[];

                          function find

                          find: {
                          <T>(arr: T[], predicate: Function): T;
                          <T>(arr: T[], predicate: object): T;
                          };

                            function findIndex

                            findIndex: <T>(
                            arr: T[],
                            predicate: (item: T, idx?: number) => boolean,
                            fromIndex?: number
                            ) => number;

                              function firstValue

                              firstValue: (data: object[], name: string) => any;

                                function fixedBase

                                fixedBase: (v: number, base: number | string) => number;

                                  function flatten

                                  flatten: <T>(arr: T[]) => T[];
                                  • Flattens array a single level deep.

                                    Parameter arr

                                    The array to flatten. {Array} Returns the new flattened array.

                                    Example 1

                                    flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]

                                  function flattenDeep

                                  flattenDeep: (arr: any[], result?: any[]) => any[];
                                  • Flattens array a single level deep.

                                    Parameter arr

                                    The array to flatten.

                                    Parameter result

                                    The array to return. {Array} Returns the new flattened array.

                                    Example 1

                                    flattenDeep([1, [2, [3, [4]], 5]]); // => [1, 2, 3, 4, 5]

                                  function forIn

                                  forIn: (elements: any[] | object, func: (v: any, k: any) => any) => void;

                                    function get

                                    get: (obj: any, key: string | any[], defaultValue?: any) => any;

                                      function getRange

                                      getRange: (values: number[]) => RangeType;

                                        function getType

                                        getType: (value: any) => string;

                                          function getWrapBehavior

                                          getWrapBehavior: (obj: object, action: string) => Function;
                                          • 获取封装的事件

                                            Parameter obj

                                            对象

                                            Parameter action

                                            事件名称 {Function} 返回事件处理函数

                                          function group

                                          group: <T>(
                                          data: T[],
                                          condition: string | string[] | ((v: T) => string)
                                          ) => T[][];

                                            function groupBy

                                            groupBy: {
                                            <T>(data: T[], condition: (item: T) => string): ObjectType<T>;
                                            <T>(data: T[], condition: string): ObjectType<T>;
                                            };

                                              function groupToMap

                                              groupToMap: (
                                              data: any,
                                              condition: string | string[] | ((row: any) => string)
                                              ) => import('./group-by').ObjectType<any> | { 0: any };
                                              • 将数据分组成 map

                                                Parameter data

                                                Parameter condition

                                              function has

                                              has: (obj: object, key: any) => boolean;

                                                function hasKey

                                                hasKey: (obj: object, key: any) => boolean;

                                                  function hasValue

                                                  hasValue: (obj: object, value: any) => boolean;
                                                    head: (o: unknown) => any;

                                                      function identity

                                                      identity: <T>(v: T) => T;

                                                        function includes

                                                        includes: (arr: any[], value: any) => boolean;

                                                          function indexOf

                                                          indexOf: <T>(arr: T[], obj: T) => number;

                                                            function isArguments

                                                            isArguments: (value: any) => boolean;

                                                              function isArray

                                                              isArray: (value: any) => value is any[];

                                                                function isArrayLike

                                                                isArrayLike: (value: any) => boolean;

                                                                  function isBoolean

                                                                  isBoolean: (value: any) => value is boolean;

                                                                    function isDate

                                                                    isDate: (value: any) => value is Date;

                                                                      function isDecimal

                                                                      isDecimal: (num: any) => boolean;

                                                                        function isElement

                                                                        isElement: (o: any) => boolean;
                                                                        • 判断是否HTML元素 {Boolean} 是否HTML元素

                                                                        function isEmpty

                                                                        isEmpty: (value: any) => boolean;

                                                                          function isEqual

                                                                          isEqual: (value: any, other: any) => boolean;

                                                                            function isEqualWith

                                                                            isEqualWith: <T>(value: T, other: T, fn: (v1: T, v2: T) => boolean) => boolean;

                                                                              function isError

                                                                              isError: (value: any) => value is Error;

                                                                                function isEven

                                                                                isEven: (num: any) => boolean;

                                                                                  function isFinite

                                                                                  isFinite: (value: any) => value is number;

                                                                                    function isFunction

                                                                                    isFunction: (value: any) => value is Function;

                                                                                      function isInteger

                                                                                      isInteger: (number: unknown) => boolean;

                                                                                        function isMatch

                                                                                        isMatch: (obj: any, attrs: any) => boolean;

                                                                                          function isNegative

                                                                                          isNegative: (num: any) => boolean;

                                                                                            function isNil

                                                                                            isNil: (value: any) => value is null;

                                                                                              function isNull

                                                                                              isNull: (value: any) => value is null;

                                                                                                function isNumber

                                                                                                isNumber: (value: any) => value is number;

                                                                                                  function isNumberEqual

                                                                                                  isNumberEqual: (a: number, b: number, precision?: number) => boolean;

                                                                                                    function isObject

                                                                                                    isObject: <T = object>(value: any) => value is T;

                                                                                                      function isObjectLike

                                                                                                      isObjectLike: (value: any) => value is object;

                                                                                                        function isOdd

                                                                                                        isOdd: (num: any) => boolean;

                                                                                                          function isPlainObject

                                                                                                          isPlainObject: (value: any) => value is object;

                                                                                                            function isPositive

                                                                                                            isPositive: (num: any) => boolean;

                                                                                                              function isPrototype

                                                                                                              isPrototype: (value: any) => boolean;

                                                                                                                function isRegExp

                                                                                                                isRegExp: (str: any) => str is RegExp;

                                                                                                                  function isString

                                                                                                                  isString: (str: any) => str is string;

                                                                                                                    function isType

                                                                                                                    isType: (value: any, type: string) => boolean;

                                                                                                                      function isUndefined

                                                                                                                      isUndefined: (value: any) => value is undefined;

                                                                                                                        function keys

                                                                                                                        keys: (obj: any) => any[];

                                                                                                                          function last

                                                                                                                          last: (o: unknown) => any;

                                                                                                                            function lowerCase

                                                                                                                            lowerCase: (str: string) => string;

                                                                                                                              function lowerFirst

                                                                                                                              lowerFirst: (value: string) => string;

                                                                                                                                function map

                                                                                                                                map: <T, G>(arr: T[], func: (v: T, idx: number) => G) => G[];

                                                                                                                                  function mapValues

                                                                                                                                  mapValues: <T>(
                                                                                                                                  object: { [key: string]: T },
                                                                                                                                  func?: (value: T, key: string) => any
                                                                                                                                  ) => { [key: string]: any };

                                                                                                                                    function max

                                                                                                                                    max: (arr: number[]) => number | undefined;

                                                                                                                                      function maxBy

                                                                                                                                      maxBy: <T>(arr: T[], fn: string | ((v: T) => number)) => T;

                                                                                                                                        function memoize

                                                                                                                                        memoize: (
                                                                                                                                        f: Function,
                                                                                                                                        resolver?: (...args: any[]) => string
                                                                                                                                        ) => { (...args: any[]): any; cache: any };

                                                                                                                                          function min

                                                                                                                                          min: (arr: number[]) => number | undefined;

                                                                                                                                            function minBy

                                                                                                                                            minBy: <T>(arr: T[], fn: string | ((v: T) => number)) => T;

                                                                                                                                              function mix

                                                                                                                                              mix: <Base, A, B, C>(
                                                                                                                                              dist: Base & A & B & C,
                                                                                                                                              src1?: A,
                                                                                                                                              src2?: B,
                                                                                                                                              src3?: C
                                                                                                                                              ) => Base & A & B & C;

                                                                                                                                                function mod

                                                                                                                                                mod: (n: number, m: number) => number;

                                                                                                                                                  function noop

                                                                                                                                                  noop: () => void;

                                                                                                                                                    function number2color

                                                                                                                                                    number2color: (num: number) => string;

                                                                                                                                                      function omit

                                                                                                                                                      omit: <T>(obj: ObjectType<T>, keys: string[]) => ObjectType<T>;

                                                                                                                                                        function parseRadius

                                                                                                                                                        parseRadius: { (radius: number): RadiusType; (radius: number[]): RadiusType };

                                                                                                                                                          function pick

                                                                                                                                                          pick: <T>(object: ObjectType<T>, keys: string[]) => ObjectType<T>;

                                                                                                                                                            function pull

                                                                                                                                                            pull: <T>(arr: T[], ...values: any[]) => T[];

                                                                                                                                                              function pullAt

                                                                                                                                                              pullAt: <T>(arr: T[], indexes: number[]) => T[];

                                                                                                                                                                function reduce

                                                                                                                                                                reduce: <T, G>(
                                                                                                                                                                arr: ObjectType<T> | G[],
                                                                                                                                                                fn: (result: T, data: G, idx: string | number) => T,
                                                                                                                                                                init: T
                                                                                                                                                                ) => T;

                                                                                                                                                                  function remove

                                                                                                                                                                  remove: <T>(
                                                                                                                                                                  arr: T[],
                                                                                                                                                                  predicate: (value: T, idx: number, arr?: T[]) => boolean
                                                                                                                                                                  ) => T[];

                                                                                                                                                                    function requestAnimationFrame

                                                                                                                                                                    requestAnimationFrame: (fn: any) => any;

                                                                                                                                                                      function set

                                                                                                                                                                      set: (obj: any, path: string | any[], value: any) => any;

                                                                                                                                                                        function size

                                                                                                                                                                        size: (o: unknown) => number;

                                                                                                                                                                          function some

                                                                                                                                                                          some: <T>(arr: T[], func: (v: T, idx?: number) => any) => boolean;
                                                                                                                                                                          • 只要有一个满足条件就返回 true

                                                                                                                                                                            Parameter arr

                                                                                                                                                                            Parameter func

                                                                                                                                                                          function sortBy

                                                                                                                                                                          sortBy: {
                                                                                                                                                                          <T>(arr: ObjectType<T>[], key: Function): ObjectType<T>[];
                                                                                                                                                                          <T>(arr: ObjectType<T>[], key: string): ObjectType<T>[];
                                                                                                                                                                          <T>(arr: ObjectType<T>[], key: string[]): ObjectType<T>[];
                                                                                                                                                                          };

                                                                                                                                                                            function startsWith

                                                                                                                                                                            startsWith: { (arr: string, e: string): boolean; <T>(arr: T[], e: T): boolean };

                                                                                                                                                                              function substitute

                                                                                                                                                                              substitute: <T>(str: string, o: ObjectType<T>) => string;

                                                                                                                                                                                function throttle

                                                                                                                                                                                throttle: (func: Function, wait: number, options: OptionsType) => Function;

                                                                                                                                                                                  function toArray

                                                                                                                                                                                  toArray: (value: any) => any[];

                                                                                                                                                                                    function toDegree

                                                                                                                                                                                    toDegree: (radian: number) => number;

                                                                                                                                                                                      function toInteger

                                                                                                                                                                                      toInteger: (s: string, radix?: number) => number;

                                                                                                                                                                                        function toRadian

                                                                                                                                                                                        toRadian: (degree: number) => number;

                                                                                                                                                                                          function toString

                                                                                                                                                                                          toString: (value: any) => string;

                                                                                                                                                                                            function union

                                                                                                                                                                                            union: (...sources: any[]) => any[];

                                                                                                                                                                                              function uniq

                                                                                                                                                                                              uniq: (arr: any[], cache?: any) => any[];

                                                                                                                                                                                                function uniqueId

                                                                                                                                                                                                uniqueId: (prefix?: string) => string;

                                                                                                                                                                                                  function upperCase

                                                                                                                                                                                                  upperCase: (str: string) => string;

                                                                                                                                                                                                    function upperFirst

                                                                                                                                                                                                    upperFirst: (value: string) => string;

                                                                                                                                                                                                      function values

                                                                                                                                                                                                      values: (obj: any) => any;

                                                                                                                                                                                                        function valuesOfKey

                                                                                                                                                                                                        valuesOfKey: (data: any[], name: string) => any[];

                                                                                                                                                                                                          function wrapBehavior

                                                                                                                                                                                                          wrapBehavior: (obj: object, action: string) => Function;
                                                                                                                                                                                                          • 封装事件,便于使用上下文this,和便于解除事件时使用

                                                                                                                                                                                                            Parameter obj

                                                                                                                                                                                                            对象

                                                                                                                                                                                                            Parameter action

                                                                                                                                                                                                            事件名称 {Function} 返回事件处理函数

                                                                                                                                                                                                          Classes

                                                                                                                                                                                                          class Cache

                                                                                                                                                                                                          class<T> {}
                                                                                                                                                                                                          • k-v 存储

                                                                                                                                                                                                          property map

                                                                                                                                                                                                          map: { [key: string]: T };

                                                                                                                                                                                                            method clear

                                                                                                                                                                                                            clear: () => void;

                                                                                                                                                                                                              method delete

                                                                                                                                                                                                              delete: (key: string) => void;

                                                                                                                                                                                                                method get

                                                                                                                                                                                                                get: (key: string, def?: T) => T | undefined;

                                                                                                                                                                                                                  method has

                                                                                                                                                                                                                  has: (key: string) => boolean;

                                                                                                                                                                                                                    method set

                                                                                                                                                                                                                    set: (key: string, value: T) => void;

                                                                                                                                                                                                                      method size

                                                                                                                                                                                                                      size: () => number;

                                                                                                                                                                                                                        Package Files (107)

                                                                                                                                                                                                                        Dependencies (1)

                                                                                                                                                                                                                        Dev Dependencies (4)

                                                                                                                                                                                                                        Peer Dependencies (0)

                                                                                                                                                                                                                        No peer dependencies.

                                                                                                                                                                                                                        Badge

                                                                                                                                                                                                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@antv/util.

                                                                                                                                                                                                                        • Markdown
                                                                                                                                                                                                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@antv/util)
                                                                                                                                                                                                                        • HTML
                                                                                                                                                                                                                          <a href="https://www.jsdocs.io/package/@antv/util"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>