Socket
Socket
Sign inDemoInstall

@dbpath/utils

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbpath/utils - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

dist/src/sort.d.ts

13

dist/index.d.ts

@@ -1,10 +0,11 @@

export * from './src/safe';
export * from './src/nameAnd';
export * from "./src/columns";
export * from './src/combine';
export * from './src/utils';
export * from './src/errors';
export * from './src/json';
export * from "./src/maputils";
export * from './src/nameAnd';
export * from './src/safe';
export * from "./src/strings";
export * from "./src/sort";
export * from './src/utils';
export * from "./src/validators";
export * from "./src/strings";
export * from "./src/columns";
export * from "./src/maputils";

@@ -17,11 +17,12 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./src/safe"), exports);
__exportStar(require("./src/nameAnd"), exports);
__exportStar(require("./src/columns"), exports);
__exportStar(require("./src/combine"), exports);
__exportStar(require("./src/utils"), exports);
__exportStar(require("./src/errors"), exports);
__exportStar(require("./src/json"), exports);
__exportStar(require("./src/maputils"), exports);
__exportStar(require("./src/nameAnd"), exports);
__exportStar(require("./src/safe"), exports);
__exportStar(require("./src/strings"), exports);
__exportStar(require("./src/sort"), exports);
__exportStar(require("./src/utils"), exports);
__exportStar(require("./src/validators"), exports);
__exportStar(require("./src/strings"), exports);
__exportStar(require("./src/columns"), exports);
__exportStar(require("./src/maputils"), exports);

@@ -9,2 +9,5 @@ export type ErrorFn<From, To> = (value: From) => ErrorsAnd<To>;

export declare function mapErrors<T, T1>(t: ErrorsAnd<T>, fn: (t: T) => ErrorsAnd<T1>): ErrorsAnd<T1>;
export declare function mapAndforEachErrorFn<T, Acc, T1>(ts: T[], mapFn: (t: T) => ErrorsAnd<T1>, forEach: (t1: T1, index: number) => Acc): ErrorsAnd<void>;
export declare function allErrorsIn<T>(ts: ErrorsAnd<T>[]): string[];
export declare function allValuesIn<T>(ts: ErrorsAnd<T>[]): T[];
export declare function mapErrorsK<T, T1>(t: ErrorsAnd<T>, fn: (t: T) => Promise<ErrorsAnd<T1>>): Promise<ErrorsAnd<T1>>;

@@ -11,0 +14,0 @@ export declare function flattenErrors<T>(t: ErrorsAnd<ErrorsAnd<T>>): ErrorsAnd<T>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.composeErrorFnAndThen = exports.composeErrorFn = exports.foldErrorsK = exports.foldErrors = exports.flatMapErrorsK = exports.flatMapErrors = exports.flattenErrors = exports.mapErrorsK = exports.mapErrors = exports.value = exports.errors = exports.hasErrors = exports.reportErrors = exports.mapArrayOfErrorsAnd = void 0;
exports.composeErrorFnAndThen = exports.composeErrorFn = exports.foldErrorsK = exports.foldErrors = exports.flatMapErrorsK = exports.flatMapErrors = exports.flattenErrors = exports.mapErrorsK = exports.allValuesIn = exports.allErrorsIn = exports.mapAndforEachErrorFn = exports.mapErrors = exports.value = exports.errors = exports.hasErrors = exports.reportErrors = exports.mapArrayOfErrorsAnd = void 0;
const utils_1 = require("./utils");

@@ -34,2 +34,19 @@ function mapArrayOfErrorsAnd(ts, fn) {

exports.mapErrors = mapErrors;
function mapAndforEachErrorFn(ts, mapFn, forEach) {
const raw = ts.map(mapFn);
const errors = allErrorsIn(raw);
if (errors.length > 0)
return errors;
const values = allValuesIn(raw);
values.forEach((t1, i) => forEach(t1, i));
}
exports.mapAndforEachErrorFn = mapAndforEachErrorFn;
function allErrorsIn(ts) {
return (0, utils_1.flatMap)(ts, t => hasErrors(t) ? errors(t) : []);
}
exports.allErrorsIn = allErrorsIn;
function allValuesIn(ts) {
return (0, utils_1.flatMap)(ts, t => hasErrors(t) ? [] : [t]);
}
exports.allValuesIn = allValuesIn;
function mapErrorsK(t, fn) {

@@ -36,0 +53,0 @@ return hasErrors(t) ? Promise.resolve(t) : fn(t);

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

const nameAnd_1 = require("./nameAnd");
const sort_1 = require("./sort");
describe('safeArray', () => {

@@ -101,1 +102,23 @@ it("should return the array if defined", () => {

});
describe("deepsort", () => {
it("should return param if not array or obejct", () => {
expect((0, sort_1.deepSort)(1)).toEqual(1);
expect((0, sort_1.deepSort)("1")).toEqual("1");
});
it("should sort arrays", () => {
expect((0, sort_1.deepSort)([[3, 2, 1], [1, 2, 3]])).toEqual([[1, 2, 3], [1, 2, 3]]);
});
it("should sort objects", () => {
expect((0, sort_1.deepSort)({ w: 1, b: { z: 1, y: [3, 2, 1] } })).toEqual({
"b": {
"y": [
1,
2,
3
],
"z": 1
},
"w": 1
});
});
});
{
"name": "@dbpath/utils",
"description": "",
"version": "0.1.0",
"version": "0.1.1",
"main": "dist/index",

@@ -6,0 +6,0 @@ "types": "dist/index",

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

General utilities for db-auto: no domain knowledge at all in any of these
General utilities for dbpath: no domain knowledge at all in any of these
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