Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ndarray-string

Package Overview
Dependencies
Maintainers
6
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndarray-string

ndarray views of strings

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created
Source

ndarray-string

Turns a string into an ndarray

build status

Example

Conversion

var ndstring = require("ndarray-string")
var x = ndstring("foobar", [2,3])
console.log(ndstring.toString(x))
["foo", "bar"]

Rotations

We can also do fancier stuff. For example, here are all rotations of "banana"

var y = ndstring("bananabanana", [6,6], [1,1])
console.log(ndstring.toString(y))
Output
[ 'banana', 'ananab', 'nanaba', 'anaban', 'nabana', 'abanan' ]

Install

Install using npm:

npm install ndarray-string

API

var ndstring = require("ndarray-string")
ndstring(str[, shape, stride, offset])

Constructs an ndarray view of str. The values of the ndarray are the full unicode code points of str. The resulting ndarray is a view of a 32 bit unsigned int typed array.

  • str is the string which gets turned into an ndarray
  • shape is the shape of the resulting ndarray
  • stride is the stride of the ndarray
  • offset is the offset

Returns An ndarray view of the code points of str

ndstring.toString(arr)

Turns an ndarray view of a string into an array of strings.

  • arr is an ndarray view of a string, for example created using the above method

Returns An array of native arrays of strings, with the strings corresponding to the last dimension of the input array (so if the input has only one dimension, only a string is returned).

License

(c) 2013 Mikola Lysenko. MIT License

Keywords

FAQs

Package last updated on 10 Jul 2015

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