Skip to content

Prepend/append string X (or ensure string X is prepended/appended) to each occurrence of string Y in string Z

Notifications You must be signed in to change notification settings

danne931/farm-life

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

farm-life

Prepend/append string X (or ensure string X is prepended/appended) to each occurrence of string Y in string Z

Build Status Coverage Status npm version JavaScript Style Guide

Install

$ npm install --save farm-life

Not using Node or a module bundler? Use a UMD build via the <script> tag.

Usage

import {
  append,
  prepend,
  ensureAppended,
  ensurePrepended
} from 'farm-life'

const haystack = '[]-$$the gr$$[]-eat gat$sby $$[]'
const needle = '$$'
const attachment = '[]-'

append(haystack, needle, attachment)  // '[]-$$[]-the gr$$[]-[]-eat gat$sby $$[]-[]'
ensureAppended(haystack, needle, attachment) // '[]-$$[]-the gr$$[]-eat gat$sby $$[]-[]'

prepend(haystack, needle, attachment)  // []-[]-$$the gr[]-$$[]-eat gat$sby []-$$[]
ensurePrepended(haystack, needle, attachment)  // '[]-$$the gr[]-$$[]-eat gat$sby []-$$[]'

About

Prepend/append string X (or ensure string X is prepended/appended) to each occurrence of string Y in string Z

Resources

Stars

Watchers

Forks

Packages

No packages published