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

split-at

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

split-at

Split a string at one or more indices

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
55
decreased by-30.38%
Maintainers
1
Weekly downloads
 
Created
Source

split-at Build Status

Split a string at one or more indices

Install

$ npm install --save split-at

Usage

var splitAt = require('split-at');

splitAt('unicorn', 2);
//=> ['uni', 'corn']

splitAt('unicorn', -2);
//=> ['unico', 'rn']

splitAt('unicorn&rainbow', [6, 7]);
//=> ['unicorn', '&', 'rainbow']

splitAt('unicorn&rainbow', 7, {remove: true});
//=> ['unicorn', 'rainbow']

API

splitAt(input, index, [options])

input

Type: string

String to be split.

index

Type: number, array of number

One or more indices. A negative index is a 1-based position from the end of the string. For example, -1 is the index of the last place in the string. Duplicate indices are removed from the index array. A negative index and positive index that refer to the same position in the string are treated as duplicates.

options

Type: object

remove

Type: boolean
Default: false

Remove the chosen indices.

Similar to the default String#split behaviour.

License

MIT © Sindre Sorhus

Keywords

FAQs

Package last updated on 14 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