@utilify/array
Advanced tools
+21
-8
| { | ||
| "name": "@utilify/array", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "A collection of utility functions for array manipulation and transformation. Simplifies common operations like chunking, flattening, shuffling, finding differences, and more.", | ||
| "keywords": [ | ||
| "array", | ||
| "after", | ||
| "before", | ||
| "chunk", | ||
| "difference", | ||
| "first", | ||
| "flattenArr", | ||
| "getRandom", | ||
| "isIterable", | ||
| "last", | ||
| "rotate", | ||
| "sanitizeArr", | ||
| "shuffle", | ||
| "swap", | ||
| "union", | ||
| "unique", | ||
| "utilify", | ||
| "utilities", | ||
| "utility functions", | ||
| "helper functions", | ||
| "JavaScript", | ||
| "TypeScript", | ||
| "productivity", | ||
| "helper functions", | ||
| "programming" | ||
| "TypeScript" | ||
| ], | ||
| "author": "Júlio Pattuzzo pattuzzo@protonmail.com", | ||
| "homepage": "https://utilify-docs.vercel.app/pt/docs/array/", | ||
| "homepage": "https://utilify-docs.vercel.app/en/docs/array/", | ||
| "license": "MIT", | ||
| "type": "module", | ||
| "main": "dist/index.js", | ||
| "module": "dist/index.mjs", | ||
| "main": "dist/index.cjs", | ||
| "module": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
@@ -23,0 +36,0 @@ "files": [ |
+100
-106
@@ -1,141 +0,135 @@ | ||
| # Array Utility Functions | ||
| # Utilitários Array | ||
| Array utility functions provide a variety of methods for manipulating and transforming arrays. These functions help simplify common operations, such as splitting, flattening, shuffling, and finding differences between arrays, among others. | ||
| As **funções utilitárias para arrays** fornecem uma variedade de métodos para manipular e transformar arrays. Elas ajudam a simplificar operações comuns, como dividir, achatar, embaralhar e encontrar diferenças entre arrays, entre outras. | ||
| ## Install | ||
| ## Instalação | ||
| To install and use the array utility functions, follow these steps: | ||
| Para instalar as funções utilitárias para arrays, use um dos seguintes comandos, dependendo do seu gerenciador de pacotes: | ||
| ```bash | ||
| npm install array-utils | ||
| ::: code-group | ||
| ```bash [npm] | ||
| npm install @utilify/array | ||
| ``` | ||
| Alternatively, you can use yarn: | ||
| ```bash [yarn] | ||
| yarn add @utilify/array | ||
| ``` | ||
| ```bash | ||
| yarn add array-utils | ||
| ```bash [pnpm] | ||
| pnpm add @utilify/array | ||
| ``` | ||
| After installation, you can import the functions into your project in two ways: | ||
| ::: | ||
| ### Namespace Import | ||
| Após a instalação, você pode importar as funções no seu projeto, utilizando ESM ou CJS. | ||
| You can import the entire module as a namespace, which will bundle all functions under a single object: | ||
| ## Uso | ||
| ```typescript | ||
| import * as ArrayUtils from 'array-utils'; | ||
| ``` | ||
| Esta biblioteca suporta tanto o sistema de módulos ESM quanto CJS. Use o método de importação que corresponda à configuração do seu projeto. | ||
| Then you can access the functions like this: | ||
| ::: code-group | ||
| ```typescript | ||
| ArrayUtils.after(array, 2); | ||
| ArrayUtils.shuffle(array); | ||
| ArrayUtils.union(array1, array2); | ||
| ```typescript [esm] | ||
| import { shuffle } from '@utilify/array'; | ||
| ``` | ||
| ### Named Imports | ||
| Alternatively, you can import specific functions by name: | ||
| ```typescript | ||
| import { after, before, chunk, difference, first, flattenArr, getRandom, isIterable, last, rotate, sanitizeArr, shuffle, swap, union, unique } from 'array-utils'; | ||
| ```javascript [cjs] | ||
| const { shuffle } = require('@utilify/array'); | ||
| ``` | ||
| Both methods work, so you can choose the one that best fits your project structure. The **namespace import** is helpful when you want to avoid name conflicts or prefer grouping all utility functions under one object. | ||
| ::: | ||
| ## Overview | ||
| ## Visão Geral | ||
| Here is an overview of the available functions in the array utility package: | ||
| Aqui está uma visão geral das funções disponíveis no pacote de utilitários para arrays: | ||
| ### [after](./after.md) | ||
| ```typescript | ||
| function after(array: any[], n: number): any[] | ||
| ``` | ||
| Returns the elements of the array after index `n`. | ||
| ### [after](./after.md) | ||
| ```typescript | ||
| function after(array: any[], n: number): any[] | ||
| ``` | ||
| Retorna os elementos do array após o índice `n`. | ||
| ### [before](./before.md) | ||
| ```typescript | ||
| function before(array: any[], n: number): any[] | ||
| ``` | ||
| Returns the elements of the array before index `n`. | ||
| ### [before](./before.md) | ||
| ```typescript | ||
| function before(array: any[], n: number): any[] | ||
| ``` | ||
| Retorna os elementos do array antes do índice `n`. | ||
| ### [chunk](./chunk.md) | ||
| ```typescript | ||
| function chunk(array: any[], size: number): any[][] | ||
| ``` | ||
| Splits the array into smaller chunks of size `size`. | ||
| ### [chunk](./chunk.md) | ||
| ```typescript | ||
| function chunk(array: any[], size: number): any[][] | ||
| ``` | ||
| Divide o array em pedaços menores de tamanho `size`. | ||
| ### [difference](./difference.md) | ||
| ```typescript | ||
| function difference(array: any[], values: any[]): any[] | ||
| ``` | ||
| Returns the elements of the array that are not present in the second array. | ||
| ### [difference](./difference.md) | ||
| ```typescript | ||
| function difference(array: any[], values: any[]): any[] | ||
| ``` | ||
| Retorna os elementos do array que não estão presentes no segundo array. | ||
| ### [first](./first.md) | ||
| ```typescript | ||
| function first(array: any[], n?: number): any[] | ||
| ``` | ||
| Returns the first `n` elements of the array. | ||
| ### [first](./first.md) | ||
| ```typescript | ||
| function first(array: any[], n?: number): any[] | ||
| ``` | ||
| Retorna os primeiros `n` elementos do array. | ||
| ### [flattenArr](./flattenArr.md) | ||
| ```typescript | ||
| function flattenArr(array: any[], depth?: number): any[] | ||
| ``` | ||
| Flattens the array to the specified depth. | ||
| ### [flattenArr](./flattenArr.md) | ||
| ```typescript | ||
| function flattenArr(array: any[], depth?: number): any[] | ||
| ``` | ||
| Achata o array até a profundidade especificada. | ||
| ### [getRandom](./getRandom.md) | ||
| ```typescript | ||
| function getRandom(array: any[]): any | ||
| ``` | ||
| Returns a random element from the array. | ||
| ### [getRandom](./getRandom.md) | ||
| ```typescript | ||
| function getRandom(array: any[]): any | ||
| ``` | ||
| Retorna um elemento aleatório do array. | ||
| ### [isIterable](./isIterable.md) | ||
| ```typescript | ||
| function isIterable(obj: any): boolean | ||
| ``` | ||
| Checks if the object is iterable. | ||
| ### [isIterable](./isIterable.md) | ||
| ```typescript | ||
| function isIterable(obj: any): boolean | ||
| ``` | ||
| Verifica se o objeto é iterável. | ||
| ### [last](./last.md) | ||
| ```typescript | ||
| function last(array: any[], n?: number): any[] | ||
| ``` | ||
| Returns the last `n` elements of the array. | ||
| ### [last](./last.md) | ||
| ```typescript | ||
| function last(array: any[], n?: number): any[] | ||
| ``` | ||
| Retorna os últimos `n` elementos do array. | ||
| ### [rotate](./rotate.md) | ||
| ```typescript | ||
| function rotate(array: any[], n: number): any[] | ||
| ``` | ||
| Rotates the elements of the array `n` positions. | ||
| ### [rotate](./rotate.md) | ||
| ```typescript | ||
| function rotate(array: any[], n: number): any[] | ||
| ``` | ||
| Rotaciona os elementos do array `n` posições. | ||
| ### [sanitizeArr](./sanitizeArr.md) | ||
| ```typescript | ||
| function sanitizeArr(array: any[], values: any[], replaceValue?: any): any[] | ||
| ``` | ||
| Removes or replaces the specified values in the array. | ||
| ### [sanitizeArr](./sanitizeArr.md) | ||
| ```typescript | ||
| function sanitizeArr(array: any[], values: any[], replaceValue?: any): any[] | ||
| ``` | ||
| Remove ou substitui os valores especificados no array. | ||
| ### [shuffle](./shuffle.md) | ||
| ```typescript | ||
| function shuffle(array: any[]): any[] | ||
| ``` | ||
| Shuffles the elements of the array. | ||
| ### [shuffle](./shuffle.md) | ||
| ```typescript | ||
| function shuffle(array: any[]): any[] | ||
| ``` | ||
| Embaralha os elementos do array. | ||
| ### [swap](./swap.md) | ||
| ```typescript | ||
| function swap(array: any[], index1: number, index2: number): any[] | ||
| ``` | ||
| Swaps the elements at positions `index1` and `index2`. | ||
| ### [swap](./swap.md) | ||
| ```typescript | ||
| function swap(array: any[], index1: number, index2: number): any[] | ||
| ``` | ||
| Troca os elementos nas posições `index1` e `index2`. | ||
| ### [union](./union.md) | ||
| ```typescript | ||
| function union(...arrays: any[][]): any[] | ||
| ``` | ||
| Returns the union of multiple arrays. | ||
| ### [union](./union.md) | ||
| ```typescript | ||
| function union(...arrays: any[][]): any[] | ||
| ``` | ||
| Retorna a união de múltiplos arrays. | ||
| ### [unique](./unique.md) | ||
| ```typescript | ||
| function unique(array: any[]): any[] | ||
| ``` | ||
| Returns an array with unique elements. | ||
| --- | ||
| ### [unique](./unique.md) | ||
| ```typescript | ||
| function unique(array: any[]): any[] | ||
| ``` | ||
| Retorna um array com elementos únicos. |
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
9294
-0.43%3
50%135
-4.26%