New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@appliedblockchain/event-recorder

Package Overview
Dependencies
Maintainers
27
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appliedblockchain/event-recorder - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

12

lib/event-recorder.js

@@ -17,2 +17,6 @@ 'use strict';

function isOk(object, source) {
return (0, _lodash.isFunction)(source) ? source(object) : (0, _lodash.isMatch)(object, source);
}
class EventRecorder {

@@ -33,3 +37,3 @@

includes(name, event, gteIndex = 0) {
includes(name, source, gteIndex = 0) {
const records = this.map.get(name);

@@ -41,3 +45,3 @@ if ((0, _lodash.isNil)(records)) {

const record = records[i];
if ((0, _lodash.isMatch)(record.event, event)) {
if (isOk(record.event, source)) {
return true;

@@ -49,3 +53,3 @@ }

async eventuallyIncludes(name, event) {
async eventuallyIncludes(name, source) {
const timeout = Date.now() + 60 * 1000;

@@ -56,3 +60,3 @@ const probeEvery = 0.1 * 1000;

while (Date.now() <= timeout) {
if (this.includes(name, event, i)) {
if (this.includes(name, source, i)) {
result = true;

@@ -59,0 +63,0 @@ break;

{
"name": "@appliedblockchain/event-recorder",
"version": "0.1.0",
"version": "0.1.1",
"description": "Event recorder simplifies evented/async tests.",

@@ -5,0 +5,0 @@ "main": "lib/event-recorder.js",

// @flow
import { isMatch, isNil } from 'lodash'
import { isMatch, isNil, isFunction } from 'lodash'
import Debug from 'debug'

@@ -10,2 +10,8 @@

type Source = Object | Object => boolean
function isOk(object: Object, source: Source): boolean {
return isFunction(source) ? source(object) : isMatch(object, source)
}
export default class EventRecorder {

@@ -28,3 +34,3 @@

includes(name: string, event: any, gteIndex: number = 0): boolean {
includes(name: string, source: Source, gteIndex: number = 0): boolean {
const records = this.map.get(name)

@@ -36,3 +42,3 @@ if (isNil(records)) {

const record = records[i]
if (isMatch(record.event, event)) {
if (isOk(record.event, source)) {
return true

@@ -44,3 +50,3 @@ }

async eventuallyIncludes(name: string, event: any): Promise<boolean> {
async eventuallyIncludes(name: string, source: Source): Promise<boolean> {
const timeout = Date.now() + 60 * 1000

@@ -51,3 +57,3 @@ const probeEvery = 0.1 * 1000

while (Date.now() <= timeout) {
if (this.includes(name, event, i)) {
if (this.includes(name, source, i)) {
result = true

@@ -54,0 +60,0 @@ break

// @flow
import EventRecorder from '../src/event-recorder'
import { get } from 'lodash'

@@ -32,1 +33,11 @@ const recorder = new EventRecorder

})
test('record + check with function', async () => {
setTimeout(() => {
recorder.record('foo', { nested: { foo: 2, bar: 3 } })
}, 2 * 1000)
expect(recorder.includes('foo', event => get(event, 'nested.bar') === 3)).toBeFalsy()
expect(await recorder.eventuallyIncludes('foo', event => get(event, 'nested.bar') === 3)).toBeTruthy()
expect(recorder.includes('foo', event => get(event, 'nested.bar') === 3)).toBeTruthy()
expect(recorder.includes('foo', event => get(event, 'nested.bar') === 2)).toBeFalsy()
})

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