Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

camelscore

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camelscore

camelCase and under_score utilities for objects.

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
629
decreased by-13.48%
Maintainers
1
Weekly downloads
 
Created
Source

Camelscore

Utility functions for converting under_score style strings to camelCase and the reverse, as well as on objects.

Also works on objects for converting all property names, as well as stripping or modifying keys before running.

API

  • camelCase(string) - convert a underscored string to camel-case. Note: leading and trailing _ will not be affected.
  • underscore(string) - convert a camel-cased string to underscores. Note: leading and trailing _ will not be affected.
  • camelize(object, fn) - convert an object's underscored property names to camel-case. Optionally run fn through map function first.
  • underscorify(object, fn) - convert an object's camel-cased property names to underscores. Optionally run fn through map function first.

Usage

var camelscore = require('camelscore');

var camelCased = camelscore.camelize({
    foo_bar: {
        hello_world: "hello world!"
    }
});

Will result in:

{
    "fooBar": {
        "helloWorld": "hello world!"
    }
}

To use map function:

var camelscore = require('camelscore');

var camelCased = camelscore.camelize({
    foo_bar: {
        hello_world: "hello world!",
        goodbye: "goodbye"
    }
}, function (k) {
    return k === 'goobye' ? undefined : k;
});

Will result in:

{
    "fooBar": {
        "helloWorld": "hello world!"
    }
}

FAQs

Package last updated on 05 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc