@code-to-json/utils
Advanced tools
Comparing version 0.5.49 to 0.6.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [0.6.0](https://github.com/mike-north/code-to-json/compare/@code-to-json/utils@0.5.49...@code-to-json/utils@0.6.0) (2019-01-04) | ||
### Features | ||
* move InvalidArgumentsError to utils ([d58dd3f](https://github.com/mike-north/code-to-json/commit/d58dd3f)) | ||
* parameterize reference system over ref-registry ([7b6d54b](https://github.com/mike-north/code-to-json/commit/7b6d54b)) | ||
## [0.5.49](https://github.com/mike-north/code-to-json/compare/@code-to-json/utils@0.5.48...@code-to-json/utils@0.5.49) (2019-01-03) | ||
@@ -8,0 +20,0 @@ |
import { Ref, RefTypes } from './ref'; | ||
export interface Queue<K extends string, T extends object> { | ||
export interface Queue<K, T extends object> { | ||
queue(item: T): Ref<K>; | ||
@@ -12,3 +12,3 @@ numUnprocessed(): number; | ||
} | ||
export declare function createQueue<K extends RefTypes, T extends object>(k: K, idGenerator: (t: T) => string): Queue<K, T>; | ||
export declare function createQueue<RefRegistry, K extends RefTypes<RefRegistry>, T extends object>(k: K, idGenerator: (t: T) => string): Queue<K, T>; | ||
//# sourceMappingURL=queue.d.ts.map |
@@ -46,2 +46,2 @@ "use strict"; | ||
exports.createQueue = createQueue; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVldWUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZGVmZXJyZWQtcHJvY2Vzc2luZy9xdWV1ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLCtCQUFpRDtBQWNqRCxTQUFnQixXQUFXLENBQ3pCLENBQUksRUFDSixXQUE2QjtJQUU3QixNQUFNLFNBQVMsR0FBRyxJQUFJLEdBQUcsRUFBdUIsQ0FBQztJQUNqRCxPQUFPO1FBQ0wsS0FBSyxDQUFDLElBQU87WUFDWCxNQUFNLFlBQVksR0FBRyxTQUFTLENB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Q0FBQztZQUNILE9BQU8sRUFBRSxjQUFjLEVBQUUsQ0FBQztRQUM1QixDQUFDO1FBQ0QsZUFBZSxDQUFDLEVBQWtDO1lBQ2hELElBQUksY0FBYyxHQUFHLENBQUMsQ0FBQztZQUN2QixJQUFJLEVBQUUsY0FBYyxFQUFFLEtBQUssRUFBRSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDLENBQUM7WUFDL0MsT0FBTyxLQUFLLEdBQUcsQ0FBQyxFQUFFO2dCQUNoQixLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUMsQ0FBQyxjQUFjLENBQUM7Z0JBQ3RDLGNBQWMsSUFBSSxLQUFLLENBQUM7YUFDekI7WUFDRCxPQUFPLEVBQUUsY0FBYyxFQUFFLENBQUM7UUFDNUIsQ0FBQztLQUNGLENBQUM7QUFDSixDQUFDO0FBM0NELGtDQTJDQyJ9 |
@@ -1,2 +0,1 @@ | ||
import RefRegistry from './ref-registry'; | ||
export interface RefId<S> { | ||
@@ -11,9 +10,9 @@ __do_not_use_this_refid: S; | ||
*/ | ||
export declare type Ref<K extends string, S extends {} = string> = [RefType<K>, RefId<S>]; | ||
export declare type Ref<K, S extends {} = string> = [RefType<K>, RefId<S>]; | ||
/** | ||
* Get a reference type for a registry | ||
*/ | ||
export declare type RefFor<K extends keyof RefRegistry> = RefRegistry[K]; | ||
export declare type RefTypes = keyof RefRegistry; | ||
export declare type AnyRef = RefRegistry[RefTypes]; | ||
export declare type RefFor<RefRegistry, K extends keyof RefRegistry> = RefRegistry[K]; | ||
export declare type RefTypes<RefRegistry> = keyof RefRegistry; | ||
export declare type AnyRef<RefRegistry> = RefRegistry[RefTypes<RefRegistry>]; | ||
/** | ||
@@ -30,3 +29,3 @@ * Check to see whether a value is a reference | ||
*/ | ||
export declare function createRef<K extends RefTypes>(type: K, id: string): Ref<K>; | ||
export declare function createRef<RefRegistry, K extends RefTypes<RefRegistry>>(type: K, id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QyJ9 | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2RlZmVycmVkLXByb2Nlc3NpbmcvcmVmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsb0NBQW1DO0FBc0JuQzs7O0dBR0c7QUFDSCxTQUFnQixLQUFLLENBQXFCLEtBQVM7SUFDakQsT0FBTyxDQUNMLENBQUMsQ0FBQyxLQUFLO1FBQ1AsQ0FBQyxDQUFDLGVBQU8sQ0FBQyxLQUFLLENBQUM7UUFDaEIsS0FBSyxDQUFDLE1BQU0sS0FBSyxDQUFDO1FBQ2xCLE9BQU8sS0FBSyxDQUFDLENBQUMsQ0FBQyxLQUFLLFFBQVE7UUFDNUIsT0FBTyxLQUFLLENBQUMsQ0FBQyxDQUFDLEtBQUssUUFBUSxDQUM3QixDQUFDO0FBQ0osQ0FBQztBQVJELHNCQVFDO0FBRUQ7Ozs7O0dBS0c7QUFDSCxTQUFnQixTQUFTLENBQ3ZCLElBQU8sRUFDUCxFQUFVO0lBRVYsT0FBTyxDQUFFLElBQTBCLEVBQUUsRUFBUyxDQUFDLENBQUM7QUFDbEQsQ0FBQztBQUxELDhCQUtDO0FBRUQ7OztHQUdHO0FBQ0gsU0FBZ0IsT0FBTyxDQUFtQixHQUFnQjtJQUN4RCxPQUFPLEdBQUcsQ0FBQyxDQUFDLENBQVEsQ0FBQztBQUN2QixDQUFDO0FBRkQsMEJBRUM7QUFFRDs7O0dBR0c7QUFDSCxTQUFnQixLQUFLLENBQWUsR0FBZ0I7SUFDbEQsT0FBTyxHQUFHLENBQUMsQ0FBQyxDQUFRLENBQUM7QUFDdkIsQ0FBQztBQUZELHNCQUVDIn0= |
export { default as UnreachableError } from './errors/unreachable'; | ||
export { default as InvalidArgumentsError } from './errors/invalid-arguments'; | ||
export { some, all, isArray } from './array'; | ||
export { Result, ErrorResult, SuccessResult } from './types'; | ||
export { Result, ErrorResult, SuccessResult, TextFileReader, FileExistenceChecker } from './types'; | ||
export { isBlank, isPresent, isEmpty, isNone } from './checks'; | ||
@@ -5,0 +6,0 @@ export { createQueue, Queue } from './deferred-processing/queue'; |
@@ -5,2 +5,4 @@ "use strict"; | ||
exports.UnreachableError = unreachable_1.default; | ||
var invalid_arguments_1 = require("./errors/invalid-arguments"); | ||
exports.InvalidArgumentsError = invalid_arguments_1.default; | ||
var array_1 = require("./array"); | ||
@@ -26,2 +28,2 @@ exports.some = array_1.some; | ||
exports.conditionallyMergeTransformed = object_1.conditionallyMergeTransformed; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxvREFBbUU7QUFBMUQseUNBQUEsT0FBTyxDQUFvQjtBQUNwQyxpQ0FBNkM7QUFBcEMsdUJBQUEsSUFBSSxDQUFBO0FBQUUsc0JBQUEsR0FBRyxDQUFBO0FBQUUsMEJBQUEsT0FBTyxDQUFBO0FBRTNCLG1DQUErRDtBQUF0RCwyQkFBQSxPQUFPLENBQUE7QUFBRSw2QkFBQSxTQUFTLENBQUE7QUFBRSwyQkFBQSxPQUFPLENBQUE7QUFBRSwwQkFBQSxNQUFNLENBQUE7QUFDNUMscURBQWlFO0FBQXhELDhCQUFBLFdBQVcsQ0FBQTtBQUNwQixpREFBa0c7QUFBcEUsd0JBQUEsT0FBTyxDQUFBO0FBQUUsc0JBQUEsS0FBSyxDQUFBO0FBQUUsc0JBQUEsS0FBSyxDQUFBO0FBQUUsMEJBQUEsU0FBUyxDQUFBO0FBQzlELHFDQUFvQztBQUEzQiw0QkFBQSxPQUFPLENBQUE7QUFDaEIsbUNBQXlEO0FBQWhELGlEQUFBLDZCQUE2QixDQUFBIn0= | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxvREFBbUU7QUFBMUQseUNBQUEsT0FBTyxDQUFvQjtBQUNwQyxnRUFBOEU7QUFBckUsb0RBQUEsT0FBTyxDQUF5QjtBQUN6QyxpQ0FBNkM7QUFBcEMsdUJBQUEsSUFBSSxDQUFBO0FBQUUsc0JBQUEsR0FBRyxDQUFBO0FBQUUsMEJBQUEsT0FBTyxDQUFBO0FBRTNCLG1DQUErRDtBQUF0RCwyQkFBQSxPQUFPLENBQUE7QUFBRSw2QkFBQSxTQUFTLENBQUE7QUFBRSwyQkFBQSxPQUFPLENBQUE7QUFBRSwwQkFBQSxNQUFNLENBQUE7QUFDNUMscURBQWlFO0FBQXhELDhCQUFBLFdBQVcsQ0FBQTtBQUNwQixpREFBa0c7QUFBcEUsd0JBQUEsT0FBTyxDQUFBO0FBQUUsc0JBQUEsS0FBSyxDQUFBO0FBQUUsc0JBQUEsS0FBSyxDQUFBO0FBQUUsMEJBQUEsU0FBUyxDQUFBO0FBQzlELHFDQUFvQztBQUEzQiw0QkFBQSxPQUFPLENBQUE7QUFDaEIsbUNBQXlEO0FBQWhELGlEQUFBLDZCQUE2QixDQUFBIn0= |
export declare type ErrorResult<E extends Error = Error> = ['error', E]; | ||
export declare type SuccessResult<T> = ['ok', T]; | ||
export declare type Result<T, E extends Error = Error> = SuccessResult<T> | ErrorResult<E>; | ||
export declare type TextFileReader = (name: string) => string; | ||
export declare type FileExistenceChecker = (name: string) => boolean; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@code-to-json/utils", | ||
"version": "0.5.49", | ||
"version": "0.6.0", | ||
"description": "", | ||
@@ -13,3 +13,3 @@ "main": "lib/src/index.js", | ||
"lint": "yarn lint:ts && yarn lint:js && yarn lint:md", | ||
"lint:ts": "tslint --project .", | ||
"lint:ts": "tslint --project . && tslint --project test", | ||
"lint:js": "eslint . --ext js,ts", | ||
@@ -29,3 +29,3 @@ "lint:md": "remark .", | ||
"chai": "4.2.0", | ||
"eslint": "5.11.1", | ||
"eslint": "5.12.0", | ||
"eslint-config-airbnb-base": "13.1.0", | ||
@@ -94,3 +94,3 @@ "eslint-config-prettier": "3.3.0", | ||
}, | ||
"gitHead": "3c98c210707964545dc2123c2a456bedc454b299" | ||
"gitHead": "b74d81c5263a2922f12e4951e92fd39533934f37" | ||
} |
import { createRef, Ref, RefTypes } from './ref'; | ||
interface EntityInfo<K extends string, T extends object> { | ||
interface EntityInfo<K, T extends object> { | ||
ref: Ref<K>; | ||
@@ -8,3 +8,3 @@ processed: boolean; | ||
export interface Queue<K extends string, T extends object> { | ||
export interface Queue<K, T extends object> { | ||
queue(item: T): Ref<K>; | ||
@@ -16,3 +16,3 @@ numUnprocessed(): number; | ||
export function createQueue<K extends RefTypes, T extends object>( | ||
export function createQueue<RefRegistry, K extends RefTypes<RefRegistry>, T extends object>( | ||
k: K, | ||
@@ -29,3 +29,3 @@ idGenerator: (t: T) => string, | ||
const id = idGenerator(item); | ||
const ref: Ref<K> = createRef(k, id); | ||
const ref: Ref<K> = createRef<RefRegistry, K>(k, id); | ||
itemToRef.set(item, { ref, processed: false }); | ||
@@ -32,0 +32,0 @@ return ref; |
import { isArray } from '../array'; | ||
import RefRegistry from './ref-registry'; | ||
@@ -14,3 +13,3 @@ export interface RefId<S> { | ||
*/ | ||
export type Ref<K extends string, S extends {} = string> = [RefType<K>, RefId<S>]; | ||
export type Ref<K, S extends {} = string> = [RefType<K>, RefId<S>]; | ||
@@ -20,6 +19,6 @@ /** | ||
*/ | ||
export type RefFor<K extends keyof RefRegistry> = RefRegistry[K]; | ||
export type RefFor<RefRegistry, K extends keyof RefRegistry> = RefRegistry[K]; | ||
export type RefTypes = keyof RefRegistry; | ||
export type AnyRef = RefRegistry[RefTypes]; | ||
export type RefTypes<RefRegistry> = keyof RefRegistry; | ||
export type AnyRef<RefRegistry> = RefRegistry[RefTypes<RefRegistry>]; | ||
@@ -46,3 +45,6 @@ /** | ||
*/ | ||
export function createRef<K extends RefTypes>(type: K, id: string): Ref<K> { | ||
export function createRef<RefRegistry, K extends RefTypes<RefRegistry>>( | ||
type: K, | ||
id: string, | ||
): Ref<K> { | ||
return [(type as any) as RefType<K>, id as any]; | ||
@@ -49,0 +51,0 @@ } |
export { default as UnreachableError } from './errors/unreachable'; | ||
export { default as InvalidArgumentsError } from './errors/invalid-arguments'; | ||
export { some, all, isArray } from './array'; | ||
export { Result, ErrorResult, SuccessResult } from './types'; | ||
export { Result, ErrorResult, SuccessResult, TextFileReader, FileExistenceChecker } from './types'; | ||
export { isBlank, isPresent, isEmpty, isNone } from './checks'; | ||
@@ -5,0 +6,0 @@ export { createQueue, Queue } from './deferred-processing/queue'; |
export type ErrorResult<E extends Error = Error> = ['error', E]; | ||
export type SuccessResult<T> = ['ok', T]; | ||
export type Result<T, E extends Error = Error> = SuccessResult<T> | ErrorResult<E>; | ||
export type TextFileReader = (name: string) => string; | ||
export type FileExistenceChecker = (name: string) => boolean; |
import { expect } from 'chai'; | ||
import { suite, test } from 'mocha-typescript'; | ||
import { createRef } from '../src/deferred-processing/ref'; | ||
import { createQueue, isRef, Queue } from '../src/index'; | ||
import { createQueue, Queue } from '../src/index'; | ||
declare module '../src/deferred-processing/ref-registry' { | ||
export default interface RefRegistry { | ||
foo: ['foo', string]; | ||
} | ||
} | ||
@suite | ||
@@ -17,3 +10,6 @@ class DeferredProcessingTests { | ||
public before() { | ||
this.q = createQueue('foo', (val: { idd: string }) => `~~${val.idd}~~`); | ||
this.q = createQueue<{ foo: any }, 'foo', { idd: string }>( | ||
'foo', | ||
(val: { idd: string }) => `~~${val.idd}~~`, | ||
); | ||
} | ||
@@ -20,0 +16,0 @@ |
@@ -5,8 +5,2 @@ import { expect } from 'chai'; | ||
declare module '../src/deferred-processing/ref-registry' { | ||
export default interface RefRegistry { | ||
foo: ['foo', string]; | ||
} | ||
} | ||
@suite | ||
@@ -13,0 +7,0 @@ class ErrorTests { |
@@ -6,8 +6,2 @@ import { expect } from 'chai'; | ||
declare module '../src/deferred-processing/ref-registry' { | ||
export default interface RefRegistry { | ||
foo: ['foo', string]; | ||
} | ||
} | ||
@suite | ||
@@ -19,3 +13,3 @@ class RefTests { | ||
expect(isRef()).to.eql(false); | ||
const r = createRef('foo', '1231'); | ||
const r = createRef<{ foo: string }, 'foo'>('foo', '1231'); | ||
expect(isRef(r)).to.eql(true); | ||
@@ -22,0 +16,0 @@ expect(isRef(['foo' as any, 99 as any])).to.eql(false); |
@@ -11,3 +11,3 @@ { | ||
"include": ["src"], | ||
"exclude": ["node_modules/**/*", "lib/**/*"] | ||
"exclude": ["lib"] | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67508
1058