@stdlib/slice-base-str2multislice
v0.2.2
Published
Parse a string-serialized MultiSlice object.
Downloads
21
Readme
str2multislice
Parse a string-serialized
MultiSlice
object.
Installation
npm install @stdlib/slice-base-str2multislice
Usage
var str2multislice = require( '@stdlib/slice-base-str2multislice' );
str2multislice( str )
Parses a string-serialized MultiSlice
object.
var s = str2multislice( 'MultiSlice(0,Slice(2,10,1),1)' );
// returns <MultiSlice>
var d = s.data;
// returns [ 0, <Slice>, 1 ]
The function returns null
if provided an invalid string.
var s = str2multislice( 'MultiSlice(foo,bar)' );
// returns null
Notes
The string serialization format must match that of a
MultiSlice
object.var Slice = require( '@stdlib/slice-ctor' ); var MultiSlice = require( '@stdlib/slice-multi' ); var s = new MultiSlice( null, new Slice( 2, 10, 1 ), 10 ); // returns <MultiSlice> var str = s.toString(); // returns 'MultiSlice(null,Slice(2,10,1),10)'
Examples
var str2multislice = require( '@stdlib/slice-base-str2multislice' );
var s = str2multislice( 'MultiSlice(null,null,null)' );
var d = s.data;
// returns [ null, null, null ]
s = str2multislice( 'MultiSlice(10,Slice(2,10,1),null)' );
d = s.data;
// returns [ 10, <Slice>, null ]
s = str2multislice( 'MultiSlice(2,Slice(2,10,1),-5)' );
d = s.data;
// returns [ 2, <Slice>, -5 ]
s = str2multislice( 'MultiSlice(foo,bar)' );
// returns null
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.