A split function that returns [limit] elements, the last being the remainder.
  • TypeScript 86.5%
  • JavaScript 8.4%
  • Shell 5.1%
Find a file
2026-03-17 09:16:20 -07:00
.husky feat: implement splitn 2022-01-14 18:43:03 -07:00
src fix: export function as both default and named, for best compatibility 2023-09-13 09:43:56 -07:00
.gitignore feat: implement splitn 2022-01-14 18:43:03 -07:00
.npmignore feat: implement splitn 2022-01-14 18:43:03 -07:00
.prettierignore feat: implement splitn 2022-01-14 18:43:03 -07:00
.prettierrc.json feat: implement splitn 2022-01-14 18:43:03 -07:00
commitlint.config.cjs feat: export in module format instead of commonjs 2022-07-28 16:22:37 -07:00
HUMAN-CONTRIBUTION-POLICY.md docs: add human contribution policy 2026-03-17 09:16:20 -07:00
jest.config.cjs feat: export in module format instead of commonjs 2022-07-28 16:22:37 -07:00
LICENSE feat: implement splitn 2022-01-14 18:43:03 -07:00
package-lock.json chore: increment version number 2023-09-13 09:45:08 -07:00
package.json chore: increment version number 2023-09-13 09:45:08 -07:00
README.md docs: add human contribution policy 2026-03-17 09:16:20 -07:00
tsconfig.cjs.json feat: export in both module format and commonjs 2022-08-18 08:24:28 -07:00
tsconfig.es.json feat: export in both module format and commonjs 2022-08-18 08:24:28 -07:00
tsconfig.json feat: export in both module format and commonjs 2022-08-18 08:24:28 -07:00

@sciactive/splitn - Split with Remainder

A split function that returns [limit] elements, the last being the remainder.

How "split" often works in other languages, sometimes called "splitn".

Usage

import splitn from '@sciactive/splitn';

splitn('a list of words', ' ', 2);
// ['a', 'list of words']

splitn('Some-Header: a-value: 1; another-value: 2;', /:\s*/, 2);
// ['Some-Header', 'a-value: 1; another-value: 2;']

Human Authorship

This project adheres to the SciActive Human Contribution Policy.

Seal of Human Authorship

License

Copyright 2022 SciActive Inc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.