New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@perfective/array

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@perfective/array

Functions to work with the Array type

  • 0.2.0-alpha.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-94.12%
Maintainers
1
Weekly downloads
 
Created
Source

Array

The @perfective/array package provides functions for the standard JS Array class:

  • Unit functions:
    • array<T>(...elements: T[]): T[]
    • arrayFromIterable<T>(elements: Iterable<T>): T[]
    • arrayFromArrayLike<T>(elements: ArrayLike<T>): T[]
    • copy<T>(array: T[]): T[] — creates a shallow copy of an array
    • concatenated<T>(initial: T[], ...arrays: T[][]): T[]
    • flatten<T>(arrays: T[][]): T[]
    • reversed<T>(array: T[]): T[] — creates a shallow reversed copy of an array
    • sorted<T>(array: T[], order?: Compare<T>): T[] — creates a shallow sorted copy of an array
  • Type guards:
    • isArray<T, V = unknown>(value: T[] | V): value is T[]
    • isNotArray<T, V = unknown>(value: T[] | V): value is V
  • Predicates:
    • isEmpty<T>(array: T[]): boolean
    • isNotEmpty<T>(array: T[]): boolean
    • includes<T>(search: T, from?: number): Predicate<T[]>
    • includedIn<T>(array: T[], from?: number): Predicate<T>
    • every<T>(condition: Predicate<T>): Predicate<T[]>
    • some<T>(condition: Predicate<T>): Predicate<T[]>
  • Properties:
    • length<T>(array: T[]): number
  • Iterators:
    • entries<T>(array: T[]): IterableIterator<[number, T]>
    • keys<T>(array: T[]): IterableIterator<number>
    • values<T>(array: T[]): IterableIterator<T>
  • Map/Reduce:
    • map<T, V>(lift: Unary<T, V>): Unary<T[], V[]>
    • reduce<T, V>(reducer: Reducer<T, V>, initial: V): Unary<T[], V>
    • reduceTo<T>(reducer: Reducer<T, T>): Unary<T[], T>
    • reduceRight<T, V>(reducer: Reducer<T, V>, initial: V): Unary<T[], V>
    • reduceRightTo<T>(reducer: Reducer<T, T>): Unary<T[], T>
    • join<T>(separator: string = ','): Unary<T[], string>
  • Immutable element operators:
    • head<T>(array: T[]): T | undefined — returns the first (head) element;
    • tail<T>(array: T[]): T | undefined — returns the last (tail) element;
    • element<T>(index: number): Unary<T[], T | undefined> — returns the element by its index;
    • find<T>(condition: Predicate<T>): Unary<T[], T | undefined>
  • Mutable element operators:
    • pop<T>(array: T[]): T | undefined
    • push<T>(...items: T[]): Unary<T[], number>
    • shift<T>(array: T[]): T | undefined
    • unshift<T>(...items: T[]): Unary<T[], number>
  • Index operators:
    • findIndex<T>(condition: Predicate<T>): Unary<T[], number | -1>
    • indexOf<T>(search: T, from?: number): Unary<T[], number | -1>
    • lastIndexOf<T>(search: T, from?: number): Unary<T[], number | -1>
  • Immutable array operators:
    • first<T>(count: number = 1): Unary<T[], T[]> — returns an array of the first count of elements.
    • last<T>(count: number = 1): Unary<T[], T[]> — returns an array of the last count of elements.
    • append<T>(element: T): Unary<T[], T[]> — returns an array with an element inserted in the end of the original array.
    • prepend<T>(element: T): Unary<T[], T[]> — returns an array with an element inserted in the beginning of the original array.
    • insert<T>(index: number, element: T): Unary<T[], T[]> — returns an array with an element inserted into the given index.
    • replace<T>(index: number, element: T): Unary<T[], T[]> — returns an array with an element replaced in the given index.
    • remove<T>(index: number): Unary<T[], T[]> — returns an array with an element removed from the given index.
    • concat<T>(...items: ConcatArray<T>[]): Unary<T[], T[]>
    • filter<T>(condition: Predicate<T>): Unary<T[], T[]>
    • slice<T>(start?: number, end?: number): Unary<T[], T[]>
    • sorted<T>(order?: Compare<T>): Unary<T[], T[]>
  • Mutable (in-place) array operators:
    • copyWithin<T>(target: number, start: number = 0, end?: number): Unary<T[], T[]>
    • fill<T>(value: T, start?: number, end?: number): Unary<T[], T[]>
    • reverse<T>(array: T[]): T[]
    • sort<T>(order?: Compare<T>): Unary<T[], T[]>
    • splice<T>(start: number, deleteCount?: number): Unary<T[], T[]>
    • spliceWith<T>(start: number, deleteCount: number, ...items: T[]): Unary<T[], T[]>
  • Procedures:
    • forEach<T>(procedure: Unary<T, void>): Unary<T[], void>

Read the full documentation in the repository.

Keywords

FAQs

Package last updated on 08 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc