Git Product home page Git Product logo

huynhsamha / js-convert-case Goto Github PK

View Code? Open in Web Editor NEW
44.0 3.0 5.0 474 KB

⛹️‍♂️ JavaScript Convert Cases Package 🏌️‍♀️ Use for both Node.JS and Browser 🎯🎯

Home Page: https://huynhsamha.github.io/js-convert-case/

License: GNU General Public License v3.0

JavaScript 85.98% HTML 0.22% TypeScript 12.86% Shell 0.95%
js-convert-case jsconvert js-camelcase js-dotcase js-headercase js-pascalcase js-pathcase js-sentencecase js-snakecase js-textcase

js-convert-case's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

js-convert-case's Issues

License clarity re MIT vs GPL

In package.json the license is listed as MIT (and this is shown on npmjs.com) but the LICENSE file actually contains the text of the GPL license (and this is what is shown on the Github page).

Is the intention dual licenses? It would be great if this could be cleared up.

Thanks!

Nested array properties are not converted

Your code is amazing. But when a nested property is an array of objects the properties of these objects are not converted. I created a fork to handle it but i guess you use TS it'll better if you can add this functionnality. And maybe convert an array of objects directly cause now if i pass an array of objects to snakeKeys for example, the properties of these objects are not converted.

Objects that have a property of type 'Date' have their values changed to be an empty object

I am using this in conjunction with Prisma

Console logging the result from Prisma results in:

{
  Id: '77ec59b4-d7c8-4907-8f61-dc468cdd11ff',
  StartDateTime: 2021-04-16T12:30:00.000Z,
}

And if I log out the typeof for StartDateTime I get

StartDateTime: object

So I know that it is a Date object.

After running the data through the camelKeys function:

  const source = camelKeys(raw, { recursive: true, recursiveInArray: true })

I end up with this

{
  "id": "77ec59b4-d7c8-4907-8f61-dc468cdd11ff",
  "startDateTime": {},
}

I am guessing that this is because it is recursively looping through the nested object that I am converting, and the Date object counts as an object, but I think you should consider handling this object in a special way and returning either the Date object or at least it's .toString() result.

Possible to convert an array directly?

Just discovered that I'm unable to convert an array unfortunately.

const data = [
  { id: 1, user_id: 1, created_at: '2021-07-20T15:40:20.170121+00:00'}, 
  {id: 2, user_id: 2, created_at: '2021-07-20T15:40:20.170121+00:00'},
];

const response = camelKeys(data, {
  recursive: true,
  recursiveInArray: true,
});
console.log(response); // returns null

Are there any plans to allow for this feature?

Adding kebab-case?

It's impressive work, thank you first of all.

Do you think to add add kebab-case ?

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.