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

deep-substring

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-substring

A utility function for creating substrings for all values of an object.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

deep-substring

npm version

A utility function for creating substrings for all values of an object, with optional support for splitting on a given separator.

Installation

Install using npm:

npm install deep-substring -D

Or yarn:

yarn install deep-substring -D

Usage

import { deepSubstring } from 'deep-substring';

deepSubstring('hello', 0, 4);
// => hell

deepSubstring(['hello', 'world'], 1, 4);
// => ['ello', 'orld']

deepSubstring({ hello: { world: 'nested string' } }, 2, 10);
// => { hello: { world: 'sted str' } }

Separators

The separator option can be used to drop any values that would otherwise exceed the start and end index.

import { deepSubstring } from 'deep-substring';

deepSubstring('one,two,three', 0, 10, { separator: ',' });
// => one,two

deepSubstring(['one two', 'three four five'], 0, 10, { separator: ' ' });
// => ['one two', 'three four']

deepSubstring({ hello: { world: ['one|two|three|four'] } }, 2, 15, { separator: '|' });
// => { hello: { world: ['two|three'] } }

Keywords

FAQs

Package last updated on 29 Sep 2022

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