1.0.3 • Published 7 years ago

until-before v1.0.3

Weekly downloads
18
License
ISC
Repository
gitlab
Last release
7 years ago

until-before

API

operand::untilBefore(pattern)

Returns the trimmed string.

Looks for a pattern in a string and, if the pattern is found, crops the string before the first occurrence of the pattern, removing the trailing remainder.

Designed for use with :: function bind syntax, as the this property should be the string to trim.

operand

String to trim.

pattern

String to look for and trim before.

Use Case

import {untilBefore} from 'until-before'

const filepath = '~/app/node_modules/foo/bar.js'

filepath::untilBefore('node_modules/')
// -> '~/app/`

See Also

const text = 'goodbye cruel world'

text::fromBefore('cruel')  // 'cruel world'
text::fromAfter('cruel')   // ' world'
text::untilBefore('cruel') // 'goodbye '
text::untilAfter('cruel')  // 'goodbye cruel'

Colophon

Made by Sebastiaan Deckers in Singapore 🇸🇬

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago