CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
strings.mjs32 linesDownload Raw Back to util
1import * as is from '../is.mjs';2import { memoize } from './memoize.mjs';3 4export const camel2dash = memoize(str => {5  return str.replace( /([A-Z])/g, v => {6    return '-' + v.toLowerCase();7  } );8});9 10export const dash2camel = memoize(str => {11  return str.replace( /(-\w)/g, v => {12    return v[1].toUpperCase();13  } );14});15 16export const prependCamel = memoize(( prefix, str ) => {17  return prefix + str[0].toUpperCase() + str.substring(1);18}, ( prefix, str ) => {19  return prefix + '$' + str;20});21 22export const capitalize = str => {23  if( is.emptyString( str ) ){24    return str;25  }26 27  return str.charAt( 0 ).toUpperCase() + str.substring( 1 );28};29 30 31export const endsWith = (string, suffix) => string.slice(-1 * suffix.length) === suffix;32 
basant307/AI_Governance_Project · CoolFace