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

pyarray

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyarray

A node module for manipulating arrays just like how you would in Python!

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

pyarray logo
pyarray

A node module for manipulating arrays just like how you would in Python!


Build Status

Install

NPM

Features

  • Supports all native javascript array methods, such as push, indexOf etc.
  • Supports native Python list methods too!
  • Not only that, but you can also use index ranges and negative indexes, no more array[array.length-1]

Methods

For detailed information about pyarray's method behaviour visit Python's official docs. Even the errors are the same!

Python methodSupported?Note
list.append(x)YesIdentical to Array.prototype.push
list.extend(L)Yes
list.insert(i, x)Yes
list.remove(x)Yes
list.pop([i])YesRenamed to pypop to avoid conflict with Array.prototype.pop
list.index(x)Yes
list.count(x)Yes
list.reverse()YesIdentical to Array.prototype.reverse
list.sort()No

Examples

import pyarray from 'pyarray'
Creating a pyarray
let fruits = pyarray(['Banana', 'Apple', 'Orange', 'Plum', 'Grape'])
Accessing elements
PythonpyarrayResult
fruitsfruits.get()['Banana', 'Apple', 'Orange', 'Plum', 'Grape']
fruits[0]fruits[0]'Banana'
fruits[-1]fruits[-1]'Grape'
fruits[0:-2]fruits['0:-2']['Banana', 'Apple', 'Orange']
fruits[0:-1:2]fruits['0:-1:2']['Banana', 'Orange']
fruits[::-1]fruits['::-1']['Grape', 'Plum', 'Orange', 'Apple', 'Banana']
You can also use the .get() method as a fallback, the syntax is
obj.get(start, end, step)

Testing

  1. Install dependencies $ npm install

  2. Run tests $ npm run test

  3. View coverage

$ istanbul cover node_modules\mocha\bin\_mocha -- dist/tests
$ open coverage/lcov-report/index.html

Keywords

FAQs

Package last updated on 08 Sep 2016

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