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

remeda

Package Overview
Dependencies
Maintainers
2
Versions
213
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remeda - npm Package Compare versions

Comparing version 1.6.2 to 1.7.0

8

dist/commonjs/groupBy.d.ts
import { NonEmptyArray, PredIndexed } from './_types';
export declare function groupBy<T>(items: readonly T[], fn: (item: T) => PropertyKey): Record<PropertyKey, NonEmptyArray<T>>;
export declare function groupBy<T>(fn: (item: T) => PropertyKey): (array: readonly T[]) => Record<PropertyKey, NonEmptyArray<T>>;
declare type Out<Value, Key extends PropertyKey = PropertyKey> = string extends Key ? Record<Key, NonEmptyArray<Value>> : number extends Key ? Record<Key, NonEmptyArray<Value>> : symbol extends Key ? Record<Key, NonEmptyArray<Value>> : Partial<Record<Key, NonEmptyArray<Value>>>;
export declare namespace groupBy {
function indexed<T, K>(array: readonly T[], fn: PredIndexed<T, PropertyKey>): Record<string, NonEmptyArray<T>>;
function indexed<T, K>(fn: PredIndexed<T, PropertyKey>): (array: readonly T[]) => Record<string, NonEmptyArray<T>>;
function strict<Value, Key extends PropertyKey = PropertyKey>(items: readonly Value[], fn: (item: Value) => Key): Out<Value, Key>;
function strict<Value, Key extends PropertyKey = PropertyKey>(fn: (item: Value) => Key): (array: readonly Value[]) => Out<Value, Key>;
namespace strict {
function indexed<Value, Key extends PropertyKey = PropertyKey>(array: readonly Value[], fn: PredIndexed<Value, Key>): Out<Value, Key>;
function indexed<Value, Key extends PropertyKey = PropertyKey>(fn: PredIndexed<Value, Key>): (array: readonly Value[]) => Out<Value, Key>;
}
}
export {};
//# sourceMappingURL=groupBy.d.ts.map

@@ -28,2 +28,12 @@ "use strict";

groupBy.indexed = indexed;
function strict() {
return (0, purry_1.purry)(_groupBy(false), arguments);
}
groupBy.strict = strict;
(function (strict) {
function indexed() {
return (0, purry_1.purry)(_groupBy(true), arguments);
}
strict.indexed = indexed;
})(strict = groupBy.strict || (groupBy.strict = {}));
})(groupBy = exports.groupBy || (exports.groupBy = {}));

@@ -19,2 +19,6 @@ "use strict";

};
var array2 = [
{ a: 'cat', b: 123 },
{ a: 'dog', b: 456 },
];
describe('data first', function () {

@@ -36,1 +40,28 @@ test('groupBy', function () {

});
describe('Result key types', function () {
test('Union of string literals', function () {
var data = groupBy_1.groupBy.strict(array2, function (x) { return x.a; });
var result = true;
expect(result).toEqual(true);
});
test('Union of number literals', function () {
var data = groupBy_1.groupBy.strict(array2, function (x) { return x.b; });
var result = true;
expect(result).toEqual(true);
});
test('string', function () {
var data = groupBy_1.groupBy.strict(array2, function (x) { return x.a; });
var result = true;
expect(result).toEqual(true);
});
test('number', function () {
var data = groupBy_1.groupBy.strict(array2, function (x) { return x.b; });
var result = true;
expect(result).toEqual(true);
});
test('string | number', function () {
var data = groupBy_1.groupBy.strict(array2, function (x) { return x.b; });
var result = true;
expect(result).toEqual(true);
});
});
export declare function toPairs<T>(object: {
[s: string]: T;
}): Array<[string, T]>;
declare type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;
declare type ObjectValues<T extends Record<PropertyKey, unknown>> = Required<T>[ObjectKeys<T>];
declare type ObjectEntry<T extends Record<PropertyKey, unknown>> = [
ObjectKeys<T>,
ObjectValues<T>
];
declare type ObjectEntries<T extends Record<PropertyKey, unknown>> = Array<ObjectEntry<T>>;
export declare namespace toPairs {
function strict<T extends Record<PropertyKey, unknown>>(object: T): ObjectEntries<T>;
}
export {};
//# sourceMappingURL=toPairs.d.ts.map

@@ -8,1 +8,7 @@ "use strict";

exports.toPairs = toPairs;
(function (toPairs) {
function strict(object) {
return Object.entries(object);
}
toPairs.strict = strict;
})(toPairs = exports.toPairs || (exports.toPairs = {}));

@@ -12,1 +12,29 @@ "use strict";

});
test('should return pairs, strict', function () {
var actual = toPairs_1.toPairs.strict({ a: 1, b: 2, c: 3 });
expect(actual).toEqual([
['a', 1],
['b', 2],
['c', 3],
]);
});
test('stricter typing', function () {
var actual = toPairs_1.toPairs.strict({ a: 1, b: 2, c: 3 });
var isEqual = true;
expect(isEqual).toEqual(true);
});
test('stricter typing with optional', function () {
var actual = toPairs_1.toPairs.strict({});
var isEqual = true;
expect(isEqual).toEqual(true);
});
test('stricter typing with undefined', function () {
var actual = toPairs_1.toPairs.strict({ a: undefined });
var isEqual = true;
expect(isEqual).toEqual(true);
});
test('stricter with a broad type', function () {
var actual = toPairs_1.toPairs.strict({ a: 1, b: 2, c: 3 });
var isEqual = true;
expect(isEqual).toEqual(true);
});
import { NonEmptyArray, PredIndexed } from './_types';
export declare function groupBy<T>(items: readonly T[], fn: (item: T) => PropertyKey): Record<PropertyKey, NonEmptyArray<T>>;
export declare function groupBy<T>(fn: (item: T) => PropertyKey): (array: readonly T[]) => Record<PropertyKey, NonEmptyArray<T>>;
declare type Out<Value, Key extends PropertyKey = PropertyKey> = string extends Key ? Record<Key, NonEmptyArray<Value>> : number extends Key ? Record<Key, NonEmptyArray<Value>> : symbol extends Key ? Record<Key, NonEmptyArray<Value>> : Partial<Record<Key, NonEmptyArray<Value>>>;
export declare namespace groupBy {
function indexed<T, K>(array: readonly T[], fn: PredIndexed<T, PropertyKey>): Record<string, NonEmptyArray<T>>;
function indexed<T, K>(fn: PredIndexed<T, PropertyKey>): (array: readonly T[]) => Record<string, NonEmptyArray<T>>;
function strict<Value, Key extends PropertyKey = PropertyKey>(items: readonly Value[], fn: (item: Value) => Key): Out<Value, Key>;
function strict<Value, Key extends PropertyKey = PropertyKey>(fn: (item: Value) => Key): (array: readonly Value[]) => Out<Value, Key>;
namespace strict {
function indexed<Value, Key extends PropertyKey = PropertyKey>(array: readonly Value[], fn: PredIndexed<Value, Key>): Out<Value, Key>;
function indexed<Value, Key extends PropertyKey = PropertyKey>(fn: PredIndexed<Value, Key>): (array: readonly Value[]) => Out<Value, Key>;
}
}
export {};
//# sourceMappingURL=groupBy.d.ts.map

@@ -24,2 +24,12 @@ import { purry } from './purry';

groupBy.indexed = indexed;
function strict() {
return purry(_groupBy(false), arguments);
}
groupBy.strict = strict;
(function (strict) {
function indexed() {
return purry(_groupBy(true), arguments);
}
strict.indexed = indexed;
})(strict = groupBy.strict || (groupBy.strict = {}));
})(groupBy || (groupBy = {}));

@@ -17,2 +17,6 @@ import { groupBy } from './groupBy';

};
var array2 = [
{ a: 'cat', b: 123 },
{ a: 'dog', b: 456 },
];
describe('data first', function () {

@@ -34,1 +38,28 @@ test('groupBy', function () {

});
describe('Result key types', function () {
test('Union of string literals', function () {
var data = groupBy.strict(array2, function (x) { return x.a; });
var result = true;
expect(result).toEqual(true);
});
test('Union of number literals', function () {
var data = groupBy.strict(array2, function (x) { return x.b; });
var result = true;
expect(result).toEqual(true);
});
test('string', function () {
var data = groupBy.strict(array2, function (x) { return x.a; });
var result = true;
expect(result).toEqual(true);
});
test('number', function () {
var data = groupBy.strict(array2, function (x) { return x.b; });
var result = true;
expect(result).toEqual(true);
});
test('string | number', function () {
var data = groupBy.strict(array2, function (x) { return x.b; });
var result = true;
expect(result).toEqual(true);
});
});
export declare function toPairs<T>(object: {
[s: string]: T;
}): Array<[string, T]>;
declare type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;
declare type ObjectValues<T extends Record<PropertyKey, unknown>> = Required<T>[ObjectKeys<T>];
declare type ObjectEntry<T extends Record<PropertyKey, unknown>> = [
ObjectKeys<T>,
ObjectValues<T>
];
declare type ObjectEntries<T extends Record<PropertyKey, unknown>> = Array<ObjectEntry<T>>;
export declare namespace toPairs {
function strict<T extends Record<PropertyKey, unknown>>(object: T): ObjectEntries<T>;
}
export {};
//# sourceMappingURL=toPairs.d.ts.map
export function toPairs(object) {
return Object.entries(object);
}
(function (toPairs) {
function strict(object) {
return Object.entries(object);
}
toPairs.strict = strict;
})(toPairs || (toPairs = {}));

@@ -10,1 +10,29 @@ import { toPairs } from './toPairs';

});
test('should return pairs, strict', function () {
var actual = toPairs.strict({ a: 1, b: 2, c: 3 });
expect(actual).toEqual([
['a', 1],
['b', 2],
['c', 3],
]);
});
test('stricter typing', function () {
var actual = toPairs.strict({ a: 1, b: 2, c: 3 });
var isEqual = true;
expect(isEqual).toEqual(true);
});
test('stricter typing with optional', function () {
var actual = toPairs.strict({});
var isEqual = true;
expect(isEqual).toEqual(true);
});
test('stricter typing with undefined', function () {
var actual = toPairs.strict({ a: undefined });
var isEqual = true;
expect(isEqual).toEqual(true);
});
test('stricter with a broad type', function () {
var actual = toPairs.strict({ a: 1, b: 2, c: 3 });
var isEqual = true;
expect(isEqual).toEqual(true);
});

2

package.json
{
"name": "remeda",
"version": "1.6.2",
"version": "1.7.0",
"description": "A utility library for JavaScript and Typescript.",

@@ -5,0 +5,0 @@ "main": "dist/commonjs/index.js",

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