npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aldoivan10/linked-array

v1.0.5

Published

Class to linked array in javascript

Readme

LinkedArray

LinkedArray es una extensión de la clase Array en TypeScript que proporciona funcionalidades avanzadas como mover, intercambiar, obtener elementos por índices negativos (similar a Python), y mucho más. Funciona como un array estándar de JavaScript, por lo que puedes usar todas sus funciones nativas junto con las nuevas capacidades.

Características principales

  • Funcionalidades adicionales como move, swap, first, last, entre otras.
  • Soporte para índices negativos, como en Python.
  • Métodos para ordenamiento flexible, incluyendo soporte para objetos y atributos anidados.
  • Totalmente compatible con TypeScript.

Instalación

Puedes instalar esta librería usando npm:

npm install @aldoivan/linked-array

pnpm add @aldoivan/linked-array

Uso

import { LinkedArray } from "@aldoivan10/linked-array"

const array = new LinkedArray(1, 2, 3, 4, 5)

console.log(array[0]) // 1
console.log(array.first()) // 1
console.log(array.last()) // 5
console.log(array[-2], array.index()) // 4 0 pero no mueve el índice interno
console.log(array.at(-1), array.index()) // 5 4

array.move(0, 2)
console.log(array) // [2, 3, 1, 4, 5]

array.swap(0, 1)
console.log(array) // [3, 2, 1, 4, 5]

console.log(array.next()) // 3
console.log(array.previous()) // 5
console.log(array.current()) // 5

const objArr = new LinkedArray({ name: "Aldo" })
const clone = objArr.clone()
clone[0].name = "Ivan"

console.log(objArr, clone) // [{ name: "Aldo" }] [{ name: "Ivan" }]

objArr.push({ name: "Lau" })
console.log(objArr) // [{ name: "Aldo" }, { name: "Lau" }]

Ordenamiento Avanzado

Numeros, cadenas, etc.

import { LinkedArray } from "@aldoivan10/linked-array"

const numArray = new LinkedArray(5, 3, 8, 1, 9)
const sortedNumArrayAsc = numArray.sorted() //  numArray.sorted({ order: "asc" })
console.log(sortedNumArrayAsc) // [1, 3, 5, 8, 9]

const sortedNumArrayDesc = numArray.sorted({ order: "desc" })
console.log(sortedNumArrayDesc) // [9, 8, 5, 3, 1]

Objetos

interface Person {
    name: string
    age: number
    address: {
        city: string
        zip: number
    }
}

const people = new LinkedArray<Person>(
    { name: "Alice", age: 30, address: { city: "New York", zip: 10001 } },
    { name: "Bob", age: 25, address: { city: "Los Angeles", zip: 90001 } },
    { name: "Charlie", age: 35, address: { city: "Chicago", zip: 60601 } }
)

const sortedPeopleByAgeAsc = people.sorted({ attr: "age" }) // order = 'asc'
console.log(sortedPeopleByAgeAsc)
// [
//     { name: 'Bob', age: 25, address: { city: 'Los Angeles', zip: 90001 } },
//     { name: 'Alice', age: 30, address: { city: 'New York', zip: 10001 } },
//     { name: 'Charlie', age: 35, address: { city: 'Chicago', zip: 60601 } }
// ]

const sortedPeopleByCityAsc = people.sorted({
    order: "desc",
    attr: "address.city",
})
console.log(sortedPeopleByCityAsc)
// [
//     { name: 'Alice', age: 30, address: { city: 'New York', zip: 10001 } },
//     { name: 'Bob', age: 25, address: { city: 'Los Angeles', zip: 90001 } },
//     { name: 'Charlie', age: 35, address: { city: 'Chicago', zip: 60601 } },
// ]

Métodos

  • clean(): Limpia el array.
  • replace(array: Array<T>, index?: number): Reemplaza el contenido del array e inicializa el índice interno.
  • first(): Retorna el primer elemento del array.
  • last(): Retorna el último elemento del array.
  • current(): Retorna el elemento actual según el índice interno.
  • move(fromIndex: number, toIndex: number): Mueve un elemento a una nueva posición.
  • swap(index1: number, index2: number): Intercambia dos elementos.
  • next(): Retorna el siguiente elemento (con índice circular).
  • previous(): Retorna el elemento anterior (con índice circular).
  • index(): Retorna el índice interno actual.
  • at(index: number): Retorna el elemento en una posición específica.
  • clone(): Clona el array (incluidos los objetos internos).
  • removeAt(index: number): Elimina un elemento en una posición dada.
  • sorted({ order?: 'asc' | 'desc' = 'asc', attr?: string }?): Ordena el array según los parámetros.

Licencia

Este proyecto está licenciado bajo la Licencia MIT.