Giter Site home page Giter Site logo

camelize2's Introduction

camelize2

Super handy and flexible library for transforming any-shape key strings to camel-case

build status

Why do we need camelize2?

camelize is a great and simple library. But unfortunately repository seems to be dead and has not been updated for a long time.

Camelize2 for the resque!

✅ This library provides new features according to developer needs.

✅ This library fixes issues of camelize.

✅ This library uses Mocha for testing

✅ This library is opened for contributing.

Initially was forked from camelize.

Examples

const camelize = require('camelize2')

// You can pass strings
camelize('Foo-Bar')
//=> 'fooBar'


// You can pass objects
camelize({
    'abc.xyz': 'mno'
})
//=> {'abcXyz': 'mno'}


// You can pass arrays 
camelize([
     { 'abc.xyz': 'mno' },
     { 'foo-bar': 'baz' }
 ])
//=> [{'abcXyz': 'mno'}, {'fooBar': 'baz'}]


// Also you can pass more complex structures
camelize({
    fee_fie_foe: 'fum',
    beep_boop: [
        { 'abc.xyz': 'mno' },
        { 'foo-bar': 'baz' }
    ]
});
//=>    {
//=>        "feeFieFoe": "fum",
//=>        "beepBoop": [
//=>            {
//=>                "abcXyz": "mno"
//=>            },
//=>            {
//=>                "fooBar": "baz"
//=>            }
//=>        ]
//=>    }


// In case you passed other types, you get them back
camelize(true)
//=> true

When to use camelize2?

Let's say you've got following response from backend:

{
  "items": [
    {
      "product_name": "Table",
      "product_category_tags": [
        "chip",
        "handy"
      ],
      "short_url": "http://as.is/941"
    },
    {
      "product_name": "Chair",
      "product_category_tags": [
      ],
      "short_url": "http://as.is/943"
    }
  ],
  "count": 2
}

With camelcase2 you can easily convert to camel case:

{
  "items": [
    {
      "productName": "Table",
      "productCategoryTags": [
        "chip",
        "handy"
      ],
      "shortUrl": "http://as.is/941"
    },
    {
      "productName": "Chair",
      "productCategoryTags": [
      ],
      "shortUrl": "http://as.is/943"
    }
  ],
  "count": 2
}

Installing

NPM

npm install camelize2

Running the tests

You can run Mocha tests with the following command:

npm run test

Contributing

Please read CONTRIBUTING.md for the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • James Halliday - Initial work - camelize
  • Denys Ivko - Inspired follower -

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

camelize2's People

Contributors

denysivko avatar raynos avatar mafintosh avatar

Stargazers

Lisa Grabovska avatar Daniel Mircea avatar Mike Piccolo avatar Reggi avatar

Watchers

James Cloos avatar

Forkers

danwetherald

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.