Sha256: b4286d1de9222d6d9d3cfbf9c5515548ca22c977dcd74400f434e938e7fc8379

Contents?: true

Size: 799 Bytes

Versions: 469

Compression:

Stored size: 799 Bytes

Contents

import { filter } from 'lodash'

const isEmpty = (value: string | unknown): boolean => !value || value == ''

const titleizedWord = (word: string): string => (
  word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
)

export const titleize = (sentence: string): string => (
  isEmpty(sentence) ? sentence : sentence.split(' ').map(titleizedWord).join(' ')
)

const notEmpty = (value: string | Record<string, unknown>): boolean => !isEmpty(value)

export const joinPresent = (array: string[], separator: string): string => (
  filter(array, notEmpty).join(separator)
)

export const camelToSnakeCase = (word: string): string => {
  return word.split(/([A-Z])/g).map((w, i) => {
    const prefix = i > 0 ? '_' : ''
    return w === w.toLowerCase() ? w : prefix + w.toLowerCase()
  }).join("")
}

Version data entries

469 entries across 469 versions & 1 rubygems

Version Path
playbook_ui-14.6.2 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.7.0.pre.rc.2 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.alpha.dropdownclassfix4224 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.alpha.PBNTR5554223 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.alpha.PLAY1485selectablecardoverflowoutlinebug4222 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.1 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.7.0.pre.rc.1 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.alpha.play1586datearea4218 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.alpha.PBNTR5554217 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.7.0.pre.rc.0 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.5.0.pre.alpha.PLAY1485selectablecardoverflowoutlinebug4216 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.rc.25 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.rc.24 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.rc.23 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.rc.22 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.rc.21 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.5.0.pre.alpha.PLAY1548intltelinputupdatelatest4175 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.6.0.pre.rc.20 app/pb_kits/playbook/utilities/text.ts
playbook_ui-14.5.0.pre.alpha.PLAY1548intltelinputupdatelatest4162 app/pb_kits/playbook/utilities/text.ts