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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@teaplus2024/cumque-inventore-ipsum-quidem

v1.0.0

Published

Downloads

3

Readme

Array View for TypeScript and JavaScript

npm npm Coverage Status Build and test Minified Size License: MIT

Array View Logo

Array View is a TypeScript library that provides a powerful set of utilities for working with arrays in a versatile and efficient manner. These classes enable developers to create views of arrays, manipulate data with ease, and select specific elements using index lists, masks, and slice parameters.

Array View offers a Python-like slicing experience for efficient data manipulation and selection of array elements.

Features

  • Create array views for easy data manipulation.
  • Select elements using Python-like slice notation.
  • Handle array slicing operations with ease.
  • Enable efficient selection of elements using index lists and boolean masks.

Installation

npm install @teaplus2024/cumque-inventore-ipsum-quidem

Quick examples

Slicing

import { view } from "@teaplus2024/cumque-inventore-ipsum-quidem";

const originalArray = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const originalView = view(originalArray);

originalView.loc['1:7:2']; // [2, 4, 6]
originalView.loc[':3']; // [1, 2, 3]
originalView.loc['::-1']; // [9, 8, 7, 6, 5, 4, 3, 2, 1]

originalView.loc[2]; // 3
originalView.loc[4]; // 5
originalView.loc[-1]; // 9
originalView.loc[-2]; // 8

originalView.loc['1:7:2'] = [22, 44, 66];
originalArray; // [1, 22, 3, 44, 5, 66, 7, 8, 9]

Subviews

import { view, mask, select, slice } from "@teaplus2024/cumque-inventore-ipsum-quidem";

const originalArray = [1, 2, 3, 4, 5];
const originalView = view(originalArray);

originalView.subview(mask([true, false, true, false, true])).toArray(); // [1, 3, 5]
originalView.subview(select([1, 2, 4])).toArray(); // [2, 3, 5]
originalView.subview(slice('::-1')).toArray(); // [5, 4, 3, 2, 1]
originalView.subview(slice([,,-1])).toArray(); // [5, 4, 3, 2, 1]

originalView.subview(mask([true, false, true, false, true])).apply((x: number) => x * 10);
originalArray; // [10, 2, 30, 4, 50]

Combining subviews

import { view, mask, select, slice } from "@teaplus2024/cumque-inventore-ipsum-quidem";

const originalArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const subview = view(originalArray)
  .subview('::2')                                 // [1, 3, 5, 7, 9]
  .subview(mask([true, false, true, true, true])) // [1, 5, 7, 9]
  .subview(select([0, 1, 2]))                     // [1, 5, 7]
  .subview('1:')                                  // [5, 7]

subview.loc[':'] = [55, 77];
originalArray; // [1, 2, 3, 4, 55, 6, 77, 8, 9, 10]

Mask example

import { view, mask } from "@teaplus2024/cumque-inventore-ipsum-quidem";

const array1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const array2 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10];

const mask = view(array1).is((x: number) => x % 3 === 0);
// MaskSelector([false, false, true, false, false, true, false, false, true, false])

view(array2)
  .subview(mask)
  .applyWith(
    view(array1).subview(mask),
    (lhs: number, rhs: number) => lhs + rhs,
  )
  .toArray();
// [-1, -2, 0, -4, -5, 0, -7, -8, 0, -10]);

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request on the GitHub repository.

License

Array View TS is released under the MIT License.