Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dash-os/to-redux-type
Converts camel-case to screaming-snake-case (myValue -> MY_VALUE)
https://github.com/dash-os/to-redux-type
Last synced: 6 days ago
JSON representation
Converts camel-case to screaming-snake-case (myValue -> MY_VALUE)
- Host: GitHub
- URL: https://github.com/dash-os/to-redux-type
- Owner: Dash-OS
- Created: 2017-05-28T04:22:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-10T01:50:33.000Z (about 6 years ago)
- Last Synced: 2024-11-06T23:22:28.991Z (8 days ago)
- Language: JavaScript
- Size: 37.1 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# to-redux-type
Converts camelCase to SCREAMING_SNAKE_CASE with special considerations for wildcard
(*) and handling of short strings (systemRX vs systemRx --> SYSTEM_RX)> By design, for arrays and objects, values that start with @ are not converted and
> instead are returned without the @ included. This is not escapeable at this time.### Simple Example
```js
import ToReduxType from 'to-redux-type'// string
const pre = 'myValue'
const post = ToReduxType(pre) ; // MY_VALUE
// object
const pre2 = {
myValue: 'my value!',
'SYSTEM_*': 'system wildcard',
'@noCONVERT': 'no conversion'
}const post2 = ToReduxType(pre2) ;
// { MY_VALUE: 'my value!', 'SYSTEM_*': 'system wildcard', 'noCONVERT': 'no conversion' }// array
const pre3 = [ 'myValue', 'ANOTHER_VALUE', '@@@noCONVERT' ]
const post3 = ToReduxType(pre3) ; // [ 'MY_VALUE', 'ANOTHER_VALUE', '@@noCONVERT' ]
```