JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 142
  • Score
    100M100P100Q150518F
  • License MIT

Naming Conventions Modeler

Package Exports

  • naming-conventions-modeler
  • naming-conventions-modeler/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (naming-conventions-modeler) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Naming Conventions Modeler

npm Coverage Snyk Vulnerabilities for GitHub Repo npm node-current GitHub semantic-release: angular code style: prettier 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

Supported naming convention model comparison.

Original snake_case camelCase PascalCase MACRO_CASE kebab-case
RegExr reg_exr regExr RegExr REG_EXR reg-exr
PCRE pcre pcre Pcre PCRE pcre
JavaScript java_script javaScript JavaScript JAVA_SCRIPT java-script
JSProgrammingLanguage js_programming_language jsProgrammingLanguage JsProgrammingLanguage JS_PROGRAMMING_LANGUAGE js-programming-language
OTP otp otp Otp OTP otp
__meta__ meta meta Meta META meta
camelCase camel_case camelCase CamelCase CAMEL_CASE camel-case
_id id id Id ID id
ID id id Id ID id

Modeler

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

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

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

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 } ],
  id: 123,
  testValue: 'test value',
  noName: 'no name',
  noValue: 'no value'
}`

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