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

@bedrock-ui/utils

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bedrock-ui/utils - npm Package Compare versions

Comparing version 0.0.10 to 0.1.0

2

lib/cjs/utils/keyBy/keyBy.js

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

if (map.has(element[property])) {
console.warn(`duplicate key for keyBy: "${element[property]}" already exists in the map`);
console.warn(`keyBy - duplicate key: "${element[property]}" already exists in the map`);
}

@@ -11,0 +11,0 @@ map.set(element[property], element);

import type { TypeofArray } from '../../types/array';
type Order = 'asc' | 'desc';
export declare function orderBy<T extends TypeofArray<T>[], P extends keyof TypeofArray<T>>(array: T, property: P, order?: Order): T[number][];
export declare function orderBy<T extends TypeofArray<T>[], P extends keyof TypeofArray<T>>(array: T, properties: P[], orders: Order[]): T[number][];
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.orderBy = void 0;
function sortFn(a, b, order) {
function sortFn(a, b) {
if (typeof a === 'string' && typeof b === 'string') {

@@ -16,9 +16,21 @@ return a.localeCompare(b, 'en', { sensitivity: 'base' });

}
function orderBy(array, property, order = 'asc') {
const sortedArray = [...array].sort((a, b) => sortFn(a[property], b[property], order));
if (order === 'desc') {
return sortedArray.reverse();
function orderBy(array, properties, orders) {
if (properties.length !== orders.length) {
console.warn(`orderBy - property and order arrays are not the same length - properties: ${properties}, orders: ${orders}`);
}
return sortedArray;
return [...array].sort((a, b) => properties
.map((property, index) => {
const order = orders[index];
if (order === 'desc') {
return sortFn(b[property], a[property]);
}
return sortFn(a[property], b[property]);
})
.reduce((accumulator, current) => {
if (accumulator === 0) {
return current;
}
return accumulator;
}, 0));
}
exports.orderBy = orderBy;

@@ -5,3 +5,3 @@ export function keyBy(array, property) {

if (map.has(element[property])) {
console.warn(`duplicate key for keyBy: "${element[property]}" already exists in the map`);
console.warn(`keyBy - duplicate key: "${element[property]}" already exists in the map`);
}

@@ -8,0 +8,0 @@ map.set(element[property], element);

import type { TypeofArray } from '../../types/array';
type Order = 'asc' | 'desc';
export declare function orderBy<T extends TypeofArray<T>[], P extends keyof TypeofArray<T>>(array: T, property: P, order?: Order): T[number][];
export declare function orderBy<T extends TypeofArray<T>[], P extends keyof TypeofArray<T>>(array: T, properties: P[], orders: Order[]): T[number][];
export {};

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

function sortFn(a, b, order) {
function sortFn(a, b) {
if (typeof a === 'string' && typeof b === 'string') {

@@ -13,8 +13,20 @@ return a.localeCompare(b, 'en', { sensitivity: 'base' });

}
export function orderBy(array, property, order = 'asc') {
const sortedArray = [...array].sort((a, b) => sortFn(a[property], b[property], order));
if (order === 'desc') {
return sortedArray.reverse();
export function orderBy(array, properties, orders) {
if (properties.length !== orders.length) {
console.warn(`orderBy - property and order arrays are not the same length - properties: ${properties}, orders: ${orders}`);
}
return sortedArray;
return [...array].sort((a, b) => properties
.map((property, index) => {
const order = orders[index];
if (order === 'desc') {
return sortFn(b[property], a[property]);
}
return sortFn(a[property], b[property]);
})
.reduce((accumulator, current) => {
if (accumulator === 0) {
return current;
}
return accumulator;
}, 0));
}
{
"name": "@bedrock-ui/utils",
"version": "0.0.10",
"version": "0.1.0",
"description": "Bedrock UI Utils",

@@ -5,0 +5,0 @@ "author": "Matthew Wolfe",

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