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

@erickmerchant/conditional-watch

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@erickmerchant/conditional-watch - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

17

index.js

@@ -6,8 +6,17 @@ const watch = require('recursive-watch')

if (conditional) {
watch(directory, debounce(function () {
fn()
}, options || {wait: 150}))
let files = []
let debounced = debounce(function () {
fn(files)
files = []
}, options || {wait: 150})
watch(directory, function (file) {
files.push(file)
debounced()
})
}
return fn()
fn()
}
{
"name": "@erickmerchant/conditional-watch",
"version": "1.0.0",
"version": "2.0.0",
"description": "Watch using recursive-watch or not",

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

@@ -17,3 +17,3 @@ const test = require('tape')

test('true', function (t) {
test('true - watching', function (t) {
mockery.enable(mockerySettings)

@@ -32,6 +32,6 @@

fn()
fn('a-file')
})
require('./index')(true, './foo', function () {
require('./index')(true, './foo', function (files) {
t.ok(1)

@@ -41,2 +41,28 @@ })

mockery.disable()
mockery.deregisterAll()
})
test('true - debounced', function (t) {
mockery.enable(mockerySettings)
t.plan(2)
mockery.registerMock('recursive-watch', function (directory, fn) {
t.equal(directory, './foo')
fn('a-file')
fn('b-file')
})
require('./index')(true, './foo', function (files) {
if (files) {
t.deepEqual(files, ['a-file', 'b-file'])
}
})
mockery.disable()
mockery.deregisterAll()
})
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