UNPKG

@dipscope/type-manager

Version:

Transform JSON strings or plain objects into JS class instances.

17 lines 510 B
import { getWords } from '../functions/get-words'; export class SnakeCaseNamingConvention { convert(name) { return getWords(name).reduce(this.reduce, ''); } reduce(result, word, index) { if (word.length === 0) { return result; } const wordLowerCased = word.toLowerCase(); if (index === 0) { return wordLowerCased; } return `${result}_${wordLowerCased}`; } } //# sourceMappingURL=snake-case-naming-convention.js.map