npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

naming-conventions-modeler

v1.4.4

Published

Naming Conventions Modeler

Downloads

190

Readme

Naming Conventions Modeler

npm Coverage npm GitHub Gitter documentation Build, Test and Publish

Simple and Fast TypeSafe naming conventions modeler implemented with Proxy; zero dependency.

Quick Start Guide

npm install --save naming-conventions-modeler

| Original | snake_case | camelCase | PascalCase | kebab-case | MACRO_CASE | Train-Case | flatcase | no case | | ------------------------- | ----------------------- | --------------------- | --------------------- | ----------------------- | ----------------------- | ----------------------- | --------------------- | ----------------------- | | RegExr | reg_exr | regExr | RegExr | reg-exr | REG_EXR | Reg-Exr | regexr | Reg Exr | | PCRE | pcre | pcre | PCRE | pcre | PCRE | PCRE | pcre | PCRE | | JavaScript | java_script | javaScript | JavaScript | java-script | JAVA_SCRIPT | Java-Script | javascript | Java Script | | JSProgrammingLanguage | js_programming_language | jsProgrammingLanguage | JSProgrammingLanguage | js-programming-language | JS_PROGRAMMING_LANGUAGE | JS-Programming-Language | jsprogramminglanguage | JS Programming Language | | OTP | otp | otp | OTP | otp | OTP | OTP | otp | OTP | | Train-Case | train_case | trainCase | TrainCase | train-case | TRAIN_CASE | Train-Case | traincase | Train Case | | __meta__ | meta | meta | Meta | meta | META | Meta | meta | meta | | camelCase | camel_case | camelCase | CamelCase | camel-case | CAMEL_CASE | Camel-Case | camelcase | camel Case | | _id | id | id | Id | id | ID | Id | id | id | | ID | id | id | ID | id | ID | ID | id | ID | | iD | id | id | ID | id | ID | ID | id | iD | | id | id | id | Id | id | ID | Id | id | id | | Id | id | id | Id | id | ID | Id | id | Id | | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | | _-$#@ | $#@ | $#@ | $#@ | $#@ | $#@ | $#@ | $#@ | $#@ |

Modeler

import { Modeler, lookup } from 'naming-conventions-modeler';

let obj = {
  _id: 123,
  TestValue: 'test value',
  data: {
    _id: 456,
    test_value: '456',
  },
  items: [
    {
      _id: 789,
      test_value: '789',
    },
  ],
  __meata__: 'metadata',
};

type camelObj = {
  // type safety support
  id: number;
  testValue: string;
  data: {
    id: number;
    testValue: string;
    [x: string]: any;
  };
  items: [
    {
      id: number;
      testValue: string;
    },
  ];
  meta: string;
  [x: string]: any;
};

// Replace misspell keys by regex
obj = lookup(obj, { '__me.*ta__': '__meta__' });

const model = Modeler.build<camelObj>(obj, 'camelCase');

console.log(model.id); // 123

console.log(model.testValue); // test value
console.log(model.TestValue); // test value

console.log(model.data.id); // 456
console.log(model.items[0].testValue); // 789

// Set value dynamically
model.NO_name = 'no name';
model.NO_VALUE = 'no value';

console.log(model.noName); // no name
console.log(model.noValue); // no value

/**
 * It takes an convention model and converts all properties at once
 */
Modeler.convert(model);

console.log(model);
/**
 * {
 *   data: { id: 456, testValue: '456' },
 *   items: [ { testValue: '789', id: 789 } ],
 *   testValue: 'test value',
 *   noName: 'no name',
 *   noValue: 'no value',
 *   id: 123,
 *   meta: 'metadata'
 * }
 */

Tools

import { convention, toSnakeCase, isSnakeCase } from 'naming-conventions-modeler';

const str = 'JSProgrammingLanguage';

const camelCase = convention('camelCase');

console.log(camelCase.to(str)); // jsProgrammingLanguage

console.log(toSnakeCase(str)); // js_programming_language

console.log(isSnakeCase(toSnakeCase(str))); // true

License

MIT