JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q8907F
  • License ISC

Cut a string before a pattern

Package Exports

  • from-before

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (from-before) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

from-before

API

operand::fromBefore(pattern)

Returns the trimmed string.

Looks for a pattern in a string and, if the pattern is found, cuts off the string before the first occurrence of the pattern.

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 {fromBefore} from 'from-before'

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

filepath::fromBefore('node_modules/')
// -> 'node_modules/foo/bar.js`

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 🇸🇬