New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@enonic/js-utils

Package Overview
Dependencies
Maintainers
4
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enonic/js-utils - npm Package Compare versions

Comparing version 0.34.0 to 0.34.1

dist/cjs/object/sortKeys.d.ts

14

dist/cjs/array/sortBy.js

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

var isNumber_1 = require("../value/isNumber");
var value_1 = require("../value");
var isObject_1 = require("../value/isObject");
var isString_1 = require("../value/isString");
var value_2 = require("../value");
var toStr_1 = require("../value/toStr");
function compareNumbers(a, b) {

@@ -30,10 +30,10 @@ return a - b;

return localArray.sort(function (a, b) {
if (!(0, value_1.isObject)(a) || !(0, value_1.isObject)(b)) {
throw new TypeError("sortByProperty: a or b not an object! a:".concat((0, value_2.toStr)(a), " b:").concat((0, value_2.toStr)(b)));
if (!(0, isObject_1.isObject)(a) || !(0, isObject_1.isObject)(b)) {
throw new TypeError("sortByProperty: a or b not an object! a:".concat((0, toStr_1.toStr)(a), " b:").concat((0, toStr_1.toStr)(b)));
}
if (!(0, hasOwnProperty_1.hasOwnProperty)(a, propertyName)) {
throw new TypeError("sortByProperty: a doesn't have a property named:'".concat(propertyName, "'! a:").concat((0, value_2.toStr)(a)));
throw new TypeError("sortByProperty: a doesn't have a property named:'".concat(propertyName, "'! a:").concat((0, toStr_1.toStr)(a)));
}
if (!(0, hasOwnProperty_1.hasOwnProperty)(b, propertyName)) {
throw new TypeError("sortByProperty: b doesn't have a property named:'".concat(propertyName, "'! b:").concat((0, value_2.toStr)(b)));
throw new TypeError("sortByProperty: b doesn't have a property named:'".concat(propertyName, "'! b:").concat((0, toStr_1.toStr)(b)));
}

@@ -50,5 +50,5 @@ var valueA = a[propertyName];

}
throw new TypeError("sortByProperty: Value of propertyName:".concat(propertyName, " is neither number nor string! a:").concat((0, value_2.toStr)(a), " b:").concat((0, value_2.toStr)(b)));
throw new TypeError("sortByProperty: Value of propertyName:".concat(propertyName, " is neither number nor string! a:").concat((0, toStr_1.toStr)(a), " b:").concat((0, toStr_1.toStr)(b)));
});
}
exports.sortByProperty = sortByProperty;
export { getIn } from './getIn';
export { hasOwnProperty } from './hasOwnProperty';
export { setIn } from './setIn';
export declare function sortKeys<T extends Object>(obj: T): T;
export declare function sortKeysRec<T extends Object>(obj: T): T;
export { sortKeys } from './sortKeys';
export { sortKeysRec } from './sortKeysRec';

@@ -10,36 +10,5 @@ "use strict";

Object.defineProperty(exports, "setIn", { enumerable: true, get: function () { return setIn_1.setIn; } });
var isArray = Array.isArray;
var keys = Object.keys;
function sortKeys(obj) {
if (typeof obj !== 'object' || isArray(obj)) {
throw new Error('sortKeys');
}
var newObject = {};
var sortedKeys = keys(obj).sort();
for (var i = 0, l = sortedKeys.length; i < l; i++) {
var k = sortedKeys[i];
newObject[k] = obj[k];
}
return newObject;
}
exports.sortKeys = sortKeys;
function sortKeysRec(obj) {
if (isArray(obj)) {
var newArray = [];
for (var i = 0, l = obj.length; i < l; i++) {
newArray[i] = sortKeysRec(obj[i]);
}
return newArray;
}
if (typeof obj !== 'object' || obj === null) {
return obj;
}
var sortedKeys = keys(obj).sort();
var newObject = {};
for (var i = 0, l = sortedKeys.length; i < l; i++) {
var k = sortedKeys[i];
newObject[k] = sortKeysRec(obj[k]);
}
return newObject;
}
exports.sortKeysRec = sortKeysRec;
var sortKeys_1 = require("./sortKeys");
Object.defineProperty(exports, "sortKeys", { enumerable: true, get: function () { return sortKeys_1.sortKeys; } });
var sortKeysRec_1 = require("./sortKeysRec");
Object.defineProperty(exports, "sortKeysRec", { enumerable: true, get: function () { return sortKeysRec_1.sortKeysRec; } });

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

var flatten_1 = require("../../array/flatten");
var value_1 = require("../../value");
var isDate_1 = require("../../value/isDate");
var isFunction_1 = require("../../value/isFunction");
var isInfinity_1 = require("../../value/isInfinity");
var isObject_1 = require("../../value/isObject");
function enonify(unknown) {

@@ -11,4 +14,4 @@ function shouldBeDeleted(unknown) {

|| typeof unknown === 'undefined'
|| (0, value_1.isFunction)(unknown)
|| (0, value_1.isInfinity)(unknown)
|| (0, isFunction_1.isFunction)(unknown)
|| (0, isInfinity_1.isInfinity)(unknown)
|| isNumberButNaN(unknown);

@@ -29,3 +32,3 @@ }

}
if ((0, value_1.isObject)(unknown)) {
if ((0, isObject_1.isObject)(unknown)) {
Object.keys(unknown).forEach(function (k) {

@@ -53,3 +56,3 @@ var value = unknown[k];

}
if ((0, value_1.isDate)(unknown)) {
if ((0, isDate_1.isDate)(unknown)) {
return unknown.toISOString();

@@ -60,3 +63,3 @@ }

}
if ((0, value_1.isInfinity)(unknown)) {
if ((0, isInfinity_1.isInfinity)(unknown)) {
return undefined;

@@ -63,0 +66,0 @@ }

@@ -0,9 +1,9 @@

export { camelize } from './camelize';
export { cleanAnyDoubleQuoteWrap } from './cleanAnyDoubleQuoteWrap';
export { fold } from './fold';
export { includes } from './includes';
export { lpad } from './lpad';
export { rpad } from './rpad';
export { startsWith } from './startsWith';
export { ucFirst } from './ucFirst';
export { unStem } from './unStem';
export declare const camelize: (str: string, removeRegex?: RegExp) => string;
export declare function lpad(u: unknown, w?: number, z?: string): string;
export declare function rpad(u: unknown, w?: number, z?: string): string;
export declare function ucFirst(string: string): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ucFirst = exports.rpad = exports.lpad = exports.camelize = exports.unStem = exports.startsWith = exports.includes = exports.fold = exports.cleanAnyDoubleQuoteWrap = void 0;
var value_1 = require("../value/");
exports.unStem = exports.ucFirst = exports.startsWith = exports.rpad = exports.lpad = exports.includes = exports.fold = exports.cleanAnyDoubleQuoteWrap = exports.camelize = void 0;
var camelize_1 = require("./camelize");
Object.defineProperty(exports, "camelize", { enumerable: true, get: function () { return camelize_1.camelize; } });
var cleanAnyDoubleQuoteWrap_1 = require("./cleanAnyDoubleQuoteWrap");

@@ -11,37 +12,11 @@ Object.defineProperty(exports, "cleanAnyDoubleQuoteWrap", { enumerable: true, get: function () { return cleanAnyDoubleQuoteWrap_1.cleanAnyDoubleQuoteWrap; } });

Object.defineProperty(exports, "includes", { enumerable: true, get: function () { return includes_1.includes; } });
var lpad_1 = require("./lpad");
Object.defineProperty(exports, "lpad", { enumerable: true, get: function () { return lpad_1.lpad; } });
var rpad_1 = require("./rpad");
Object.defineProperty(exports, "rpad", { enumerable: true, get: function () { return rpad_1.rpad; } });
var startsWith_1 = require("./startsWith");
Object.defineProperty(exports, "startsWith", { enumerable: true, get: function () { return startsWith_1.startsWith; } });
var ucFirst_1 = require("./ucFirst");
Object.defineProperty(exports, "ucFirst", { enumerable: true, get: function () { return ucFirst_1.ucFirst; } });
var unStem_1 = require("./unStem");
Object.defineProperty(exports, "unStem", { enumerable: true, get: function () { return unStem_1.unStem; } });
var camelize = function (str, removeRegex) {
if (removeRegex === void 0) { removeRegex = /\s+/g; }
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
return index === 0 ? word.toLowerCase() : word.toUpperCase();
}).replace(removeRegex, '');
};
exports.camelize = camelize;
function lpad(u, w, z) {
if (w === void 0) { w = 2; }
if (z === void 0) { z = ' '; }
var s = '' + u;
return s.length >= w
? s
: new Array(w - s.length + 1).join(z) + s;
}
exports.lpad = lpad;
function rpad(u, w, z) {
if (w === void 0) { w = 2; }
if (z === void 0) { z = ' '; }
var s = '' + u;
return s.length >= w
? s
: s + new Array(w - s.length + 1).join(z);
}
exports.rpad = rpad;
function ucFirst(string) {
if (!(0, value_1.isString)(string) || !(0, value_1.isFunction)(string.charAt)) {
return string;
}
return "".concat(string.charAt(0).toUpperCase()).concat(string.substring(1, string.length));
}
exports.ucFirst = ucFirst;

@@ -65,3 +65,3 @@ {

},
"version": "0.34.0"
"version": "0.34.1"
}
import {hasOwnProperty} from '../object/hasOwnProperty';
import {isNumber} from '../value/isNumber';
import {isObject} from '../value';
import {isObject} from '../value/isObject';
import {isString} from '../value/isString';
import {toStr} from '../value';
import {toStr} from '../value/toStr';

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

export {getIn} from './getIn';
export {hasOwnProperty} from './hasOwnProperty';
export {setIn} from './setIn';
const {isArray} = Array;
const {keys} = Object;
export function sortKeys<T extends Object>(obj: T) :T {
if (typeof obj !== 'object' || isArray(obj)) {
throw new Error('sortKeys');
}
const newObject = {} as T;
const sortedKeys = keys(obj).sort();
for (let i = 0, l = sortedKeys.length; i < l; i++) {
const k = sortedKeys[i] as keyof T;
newObject[k] = obj[k];
}
return newObject;
}
export function sortKeysRec<T extends Object>(obj :T) :T {
if (isArray(obj)) {
const newArray = [];
for (let i = 0, l = obj.length; i < l; i++) {
newArray[i] = sortKeysRec(obj[i]); // Recurse
}
return newArray as unknown as T;
}
if (typeof obj !== 'object' || obj === null) {
return obj;
}
const sortedKeys = keys(obj).sort();
const newObject = {} as T;
for (let i = 0, l = sortedKeys.length; i < l; i++) {
const k = sortedKeys[i] as keyof T;
newObject[k] = sortKeysRec(obj[k]); // Recurse
}
return newObject;
}
export {sortKeys} from './sortKeys'
export {sortKeysRec} from './sortKeysRec'
import {flatten} from '../../array/flatten';
import {
isDate,
isFunction,
isInfinity,
isObject
} from '../../value';
import {isDate} from '../../value/isDate';
import {isFunction} from '../../value/isFunction';
import {isInfinity} from '../../value/isInfinity';
import {isObject} from '../../value/isObject';

@@ -9,0 +7,0 @@

@@ -1,53 +0,9 @@

import {
isFunction,
isString
} from '../value/';
export {camelize} from './camelize';
export {cleanAnyDoubleQuoteWrap} from './cleanAnyDoubleQuoteWrap';
export {fold} from './fold';
export {includes} from './includes';
export {lpad} from './lpad';
export {rpad} from './rpad';
export {startsWith} from './startsWith';
export {ucFirst} from './ucFirst';
export {unStem} from './unStem';
export const camelize = (
str: string,
removeRegex: RegExp = /\s+/g
): string =>
str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
return index === 0 ? word.toLowerCase() : word.toUpperCase();
}).replace(removeRegex, '');
export function lpad(
u: unknown,
w: number = 2,
z: string = ' '
): string {
const s:string = '' + u; // Cast to string
return s.length >= w
? s
: new Array(w - s.length + 1).join(z) + s;
}
export function rpad(
u: unknown,
w: number = 2,
z: string = ' '
): string {
const s:string = '' + u; // Cast to string
return s.length >= w
? s
: s + new Array(w - s.length + 1).join(z);
}
export function ucFirst(string: string): string {
if(!isString(string) || !isFunction(string.charAt)) {
return string;
}
return `${
string.charAt(0).toUpperCase()
}${
string.substring(1, string.length)
}`
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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