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

@nonara/ts-helpers

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nonara/ts-helpers - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

dist/utilities/case-converters.d.ts

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [0.0.4](https://github.com/nonara/ts-helpers/compare/v0.0.3...v0.0.4) (2021-07-08)
### Features
* Add options to case-converters ([34e3010](https://github.com/nonara/ts-helpers/commit/34e3010f7f134a98279c7a639c3f86c4b35a2595))
### [0.0.3](https://github.com/nonara/ts-helpers/compare/v0.0.2...v0.0.3) (2021-07-07)

@@ -7,0 +14,0 @@

21

dist/utilities/general-utils.d.ts

@@ -1,2 +0,1 @@

import { CamelToSnakeCase, SnakeToCamelCase } from './type-helpers';
import deepCopy from 'rfdc';

@@ -45,22 +44,2 @@ import deepMerge from 'deepmerge';

export declare function normalizeAndJoinPaths(...paths: (string | undefined)[]): string;
/**
* Converts string from snake_case to camelCase
*/
export declare function snakeToCamel<T extends string>(str: T): SnakeToCamelCase<T>;
/**
* Shallow copies object, converting property keys from snake_case to camelCase
*/
export declare function snakeToCamel<T extends object>(obj: T): T extends Array<infer U> ? T : T extends null ? T : {
[K in keyof T as SnakeToCamelCase<K>]: T[K];
};
/**
* Converts string from camelCase to snake_case
*/
export declare function camelToSnake<T extends string>(str: T): CamelToSnakeCase<T>;
/**
* Shallow copies object, converting property keys from camelCase to snake_case
*/
export declare function camelToSnake<T extends object>(obj: T): T extends Array<infer U> ? T : T extends null ? T : {
[K in keyof T as CamelToSnakeCase<K>]: T[K];
};
export { deepMerge, deepCopy };

28

dist/utilities/general-utils.js

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.deepCopy = exports.deepMerge = exports.camelToSnake = exports.snakeToCamel = exports.normalizeAndJoinPaths = exports.truthyStr = exports.swallowError = exports.accForEach = exports.reverseMap = exports.cast = exports.isValidJSON = exports.isJSONObject = exports.isJSONObjectString = void 0;
exports.deepCopy = exports.deepMerge = exports.normalizeAndJoinPaths = exports.truthyStr = exports.swallowError = exports.accForEach = exports.reverseMap = exports.cast = exports.isValidJSON = exports.isJSONObject = exports.isJSONObjectString = void 0;
const rfdc_1 = __importDefault(require("rfdc"));

@@ -105,29 +105,3 @@ exports.deepCopy = rfdc_1.default;

exports.normalizeAndJoinPaths = normalizeAndJoinPaths;
// @formatter:on
function snakeToCamel(src) {
if (typeof src === 'string')
return src
.toLowerCase()
.replace(/[-_][a-zA-Z]/g, (group) => group.slice(-1).toUpperCase());
const res = Object.create(Object.getPrototypeOf(src), Object.getOwnPropertyDescriptors(src));
for (const [key, value] of Object.entries(res)) {
delete res[key];
res[snakeToCamel(key)] = value;
}
return res;
}
exports.snakeToCamel = snakeToCamel;
// @formatter:on
function camelToSnake(src) {
if (typeof src === 'string')
return src.replace(/[A-Z]/g, (group) => `_${group.toLowerCase()}`);
const res = Object.create(Object.getPrototypeOf(src), Object.getOwnPropertyDescriptors(src));
for (const [key, value] of Object.entries(res)) {
delete res[key];
res[camelToSnake(key)] = value;
}
return res;
}
exports.camelToSnake = camelToSnake;
// endregion
//# sourceMappingURL=general-utils.js.map

@@ -8,1 +8,2 @@ export * from './general-utils';

export * from './stash-utils';
export * from './case-converters';

@@ -20,2 +20,3 @@ "use strict";

__exportStar(require("./stash-utils"), exports);
__exportStar(require("./case-converters"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@nonara/ts-helpers",
"version": "0.0.3",
"version": "0.0.4",
"description": "Helpers for TypeScript projects",

@@ -12,3 +12,3 @@ "main": "dist/index.js",

"------------- ": "-------------",
"test": "jest --passWithNoTests",
"test": "jest",
"test:coverage": "jest --collect-coverage",

@@ -36,2 +36,3 @@ "------------- ": "-------------",

"@types/rfdc": "^1.1.0",
"@types/jest": "^26.0.24",
"deepmerge": "^4.2.2",

@@ -38,0 +39,0 @@ "reflect-metadata": "^0.1.13",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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