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

@code-to-json/utils

Package Overview
Dependencies
Maintainers
2
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@code-to-json/utils - npm Package Compare versions

Comparing version 1.0.0-rc.0 to 1.0.0-rc.1

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [1.0.0-rc.1](https://github.com/mike-north/code-to-json/compare/@code-to-json/utils@1.0.0-rc.0...@code-to-json/utils@1.0.0-rc.1) (2019-01-26)
### Features
* id generation can create pass along addittional information ([376b783](https://github.com/mike-north/code-to-json/commit/376b783))
# [1.0.0-rc.0](https://github.com/mike-north/code-to-json/compare/@code-to-json/utils@0.8.4...@code-to-json/utils@1.0.0-rc.0) (2019-01-25)

@@ -8,0 +19,0 @@

5

lib/src/deferred-processing/queue.d.ts

@@ -12,3 +12,6 @@ import { Ref, RefTypes } from './ref';

}
export declare function createQueue<RefRegistry, K extends RefTypes<RefRegistry>, T extends object>(k: K, idGenerator: (t: T) => string): Queue<K, T>;
export declare function createQueue<RefRegistry, K extends RefTypes<RefRegistry>, T extends object, IDInfo = string, OtherInfo = undefined>(k: K, getIdInfo: (t: T) => IDInfo, extractId?: (info: IDInfo) => {
id: string;
otherInfo?: OtherInfo;
}): Queue<K, T>;
//# sourceMappingURL=queue.d.ts.map

13

lib/src/deferred-processing/queue.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ref_1 = require("./ref");
function createQueue(k, idGenerator) {
function createQueue(k, getIdInfo, extractId = id => ({ id: id })) {
const itemToRef = new Map();

@@ -12,5 +12,6 @@ return {

}
const id = idGenerator(item);
const idInfo = getIdInfo(item);
const { id, otherInfo } = extractId(idInfo);
const ref = ref_1.createRef(k, id);
itemToRef.set(item, { ref, processed: false });
itemToRef.set(item, { ref, otherInfo, processed: false });
return ref;

@@ -24,7 +25,7 @@ },

itemToRef.forEach((value, key) => {
const { ref, processed } = value;
const { ref, processed, otherInfo } = value;
if (processed) {
return;
}
cb(ref, key);
cb(ref, key, otherInfo);
// eslint-disable-next-line no-param-reassign

@@ -48,2 +49,2 @@ value.processed = true;

exports.createQueue = createQueue;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVldWUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZGVmZXJyZWQtcHJvY2Vzc2luZy9xdWV1ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLCtCQUFpRDtBQWNqRCxTQUFnQixXQUFXLENBQ3pCLENBQUksRUFDSixXQUE2QjtJQUU3QixNQUFNLFNBQVMsR0FBRyxJQUFJLEdBQUcsRUFBb0IsQ0FBQztJQUM5QyxPQUFPO1FBQ0wsS0FBSyxDQUFDLElBQU87WUFDWCxNQUFNLFlBQVksR0FBRyxTQUFTLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQ3pDLElBQUksWUFBWSxFQUFFO2dCQUNoQixPQUFPLFlBQVksQ0FBQyxHQUFHLENBQUM7YUFDekI7WUFDRCxNQUFNLEVBQUUsR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFDLENBQUM7WUFDN0IsTUFBTSxHQUFHLEdBQVcsZUFBUyxDQUFpQixDQUFDLEVBQUUsRUFBRSxDQUFDLENBQUM7WUFDckQsU0FBUyxDQUFDLEdBQUcsQ0FBQyxJQUFJLEVBQUUsRUFBRSxHQUFHLEVBQUUsU0FBUyxFQUFFLEtBQUssRUFBRSxDQUFDLENBQUM7WUFDL0MsT0FBTyxHQUFHLENBQUM7UUFDYixDQUFDO1FBQ0QsY0FBYztZQUNaLE9BQU8sQ0FBQyxHQUFHLFNBQVMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDLEVBQUUsRUFBRSxJQUFJLEVBQUUsRUFBRSxDQU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xDQUFDLEVBQUUsQ0FBQyxDQUFDLGNBQWMsQ0FBQztnQkFDdEMsY0FBYyxJQUFJLEtBQUssQ0FBQzthQUN6QjtZQUNELE9BQU8sRUFBRSxjQUFjLEVBQUUsQ0FBQztRQUM1QixDQUFDO0tBQ0YsQ0FBQztBQUNKLENBQUM7QUFyREQsa0NBcURDIn0=
{
"name": "@code-to-json/utils",
"version": "1.0.0-rc.0",
"version": "1.0.0-rc.1",
"description": "Low-level utilities for code-to-json",

@@ -97,3 +97,3 @@ "main": "lib/src/index.js",

},
"gitHead": "bf2d4ba4b4e918a4a0f45d763dbb0fb5c6e0b908"
"gitHead": "b5598ebc60f66d111de01fdf309141ede9a006d1"
}
import { createRef, Ref, RefTypes } from './ref';
interface EntityInfo<K> {
interface EntityInfo<K, O> {
ref: Ref<K>;
otherInfo?: O;
processed: boolean;

@@ -15,7 +16,14 @@ }

export function createQueue<RefRegistry, K extends RefTypes<RefRegistry>, T extends object>(
export function createQueue<
RefRegistry,
K extends RefTypes<RefRegistry>,
T extends object,
IDInfo = string,
OtherInfo = undefined
>(
k: K,
idGenerator: (t: T) => string,
getIdInfo: (t: T) => IDInfo,
extractId: (info: IDInfo) => { id: string; otherInfo?: OtherInfo } = id => ({ id: id as any }),
): Queue<K, T> {
const itemToRef = new Map<T, EntityInfo<K>>();
const itemToRef = new Map<T, EntityInfo<K, OtherInfo>>();
return {

@@ -27,5 +35,6 @@ queue(item: T): Ref<K> {

}
const id = idGenerator(item);
const idInfo = getIdInfo(item);
const { id, otherInfo } = extractId(idInfo);
const ref: Ref<K> = createRef<RefRegistry, K>(k, id);
itemToRef.set(item, { ref, processed: false });
itemToRef.set(item, { ref, otherInfo, processed: false });
return ref;

@@ -36,10 +45,12 @@ },

},
drain<V = void>(cb: (ref: Ref<K>, item: T) => V): { processedCount: number } {
drain<V = void>(
cb: (ref: Ref<K>, item: T, otherInfo?: OtherInfo) => V,
): { processedCount: number } {
let processedCount = 0;
itemToRef.forEach((value, key) => {
const { ref, processed } = value;
const { ref, processed, otherInfo } = value;
if (processed) {
return;
}
cb(ref, key);
cb(ref, key, otherInfo);
// eslint-disable-next-line no-param-reassign

@@ -46,0 +57,0 @@ value.processed = true;

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