New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

stri

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stri

Yet another helper tool for string manipulation.

latest
npmnpm
Version
1.0.293
Version published
Maintainers
1
Created
Source

Here goes yet another string manipulation package.

Another one!?

Well, there are many other string npm packages, like string and others. stri contains functionality that I need, but other packages miss. Only a handful of functions, but useful ones.

Installation

npm i stri -S

Usage

To have all functions at your disposal, import it and then do this in your main:

Stri.includeMe()

After that all methods will be available as String members.

Methods

  • between
  • cutFirst
  • cutLast
  • getBetween
  • getBetweenClose
  • getFirst
  • getLast
  • has
  • includeMe
  • oust
  • swap

Methods

between

Static between(s, borderA, borderB, aIsFirst, bIsFirst): stringOrUndefined

returns string between borders

Parameters

NameTypeDescription
sstringOrUndefined-
borderAstringOrUndefinedleft border
borderBstringOrUndefinedright border
aIsFirstbooleantrue if borderA is first, false if is last
bIsFirstbooleantrue if borderB is first, false if is last

Returns

stringOrUndefined

Defined in

index.ts:103

cutFirst

Static cutFirst(s, splitter): stringOrUndefined

fast way to cut away a first part split by smth, for instance "lalala/hahaha/bebebe".cutFirst('/') will return "hahaha/bebebe"

Parameters

NameType
sstringOrUndefined
splitterstringOrUndefined

Returns

stringOrUndefined

Defined in

index.ts:38

cutLast

Static cutLast(s, splitter): stringOrUndefined

fast way to cut away a last part split by smth, for instance "lalala/hahaha/bebebe".cutLast('/') will return "lalala/hahaha"

Parameters

NameType
sstringOrUndefined
splitterstringOrUndefined

Returns

stringOrUndefined

Defined in

index.ts:27

getBetween

Static getBetween(s, borderA, borderB): stringOrUndefined

returns string between borderA and B. Gets between the first A and the LAST B

Parameters

NameType
sstringOrUndefined
borderAstringOrUndefined
borderBstringOrUndefined

Returns

stringOrUndefined

Defined in

index.ts:80

getBetweenClose

Static getBetweenClose(s, borderA, borderB): stringOrUndefined

returns string between borderA and B. Gets between the FIRST A and the FIRST B

Parameters

NameType
sstringOrUndefined
borderAstringOrUndefined
borderBstringOrUndefined

Returns

stringOrUndefined

Defined in

index.ts:89

getFirst

Static getFirst(s, splitter): stringOrUndefined

fast way get the first part split by smth, for instance "lalala/hahaha/bebebe".getFirst('/') will return "lalala"

Parameters

NameType
sstringOrUndefined
splitterstringOrUndefined

Returns

stringOrUndefined

Defined in

index.ts:58

getLast

Static getLast(s, splitter): stringOrUndefined

fast way to get the last part split by smth, for instance "lalala/hahaha/bebebe".getLast('/') will return "bebebe"

Parameters

NameType
sstringOrUndefined
splitterstringOrUndefined

Returns

stringOrUndefined

Defined in

index.ts:49

has

Static has(s, what): boolean

does this string contain what?

Parameters

NameType
sstringOrUndefined
whatstring

Returns

boolean

Defined in

index.ts:73

includeMe

Static includeMe(): string

needs to be called once in the very beginning of your app

Returns

string

Defined in

index.ts:18

oust

Static oust(s, what): boolean

Removes all whats in the string In fact, same as str.split(what).join('')

Parameters

NameTypeDescription
sstringOrUndefined-
whatstringOrUndefinedwhat to remove

Returns

boolean

Defined in

index.ts:117

swap

Static swap(s, from, to): undefined | string

Replaces from with to

Parameters

NameTypeDescription
sstringOrUndefined-
fromstringOrUndefinedwhat to replace
tostringOrUndefinedto what to replace

Returns

undefined | string

Defined in

index.ts:67

FAQs

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