0.1.14 • Published 7 years ago

camelcasetodjango v0.1.14

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

CamelCaseToDjango

This package was created as I needed a simple helper to switch json props notation type between front/backend. It takes JS object and changes it recursively from camel case notation (someName) to lowdash notation (some_name).

example:

var camelCaseToDjango = require('camelcasetodjango')
var obj = {
    camelCase: 1,
    camelCaseObject: {
        camelCaseInside: 'test'
    }
}
var result  = camelCaseToDjango(obj)
/*
result is equal to:
{
    camel_case: 1,
    camel_case_object: {
        camel_case_inside: 'test'
    }
}
*/

Installation:

$ npm install -camelcasetodjango

Testing:

There are few simple tests in 'test' folder. If you want to run it, you need to have Mocha and Chai installed.

$ cd node_modules/camelcasetodjango
$ npm install
$ npm run test

Options:

camelCaseToDjango(obj, sign)

Sing parameter has a default value of "_" , so it is not required, but can pass it to the function if you want to use any other value. In test there is a case with sign = '+'. These feature was NOT deeply tested so, please verify expected result and let me know if you find any issues.

License

MIT

0.1.14

7 years ago

0.1.13

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago