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

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

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

split-at

Split a string at one or more indices

Install

$ npm install split-at

Usage

import splitAt from '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(string, index, options?)

string

Type: string

String to be split.

index

Type: number | 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.

  • split-on-first - Split a string on the first occurrence of a given separator

Keywords

FAQs

Package last updated on 03 May 2021

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