@zenjs/underscore
v1.0.0
Published
A port of `node.inflection` method `.underscore`, but there are some differences in string processing:
Downloads
1
Readme
@zenjs/underscore
A port of node.inflection
method .underscore
, but there are some differences in string processing:
When the first character is _
, this _
will not be removed like node.inflection.underscore
and will still be preserved.
Installation
Install inflection through npm
npm install @zenjs/underscore
Description
This function transforms String object from camelcase to underscore.
Arguments
str
type: String
desc: The subject string.
all_upper_case
type: Boolean
desc: Default is to lowercase and add underscore prefix
Example code
const underscore = require('@zenjs/uppercase')
underscore('MessageProperties') // Return 'message_properties'
underscore('messageProperties') // Return 'message_properties'
underscore('MP') // Return 'm_p'
underscore('MP', true) // Return 'MP'
underscore('_createdAt') // Return '_created_at'