@freik/node-utils
Version:
My personal set of utilities for NodeJS
2 lines (1 loc) • 1.19 kB
JavaScript
import{isString as h}from"@freik/typechk";import*as u from"path";function S(...a){const e=new Set,o=new Set;function g(r){return e.size===0||e.has(r)}function d(r){return o.size!==0&&o.has(r)}function f(...r){for(const t of r)for(const n of h(t)?[t]:t)e.add(n),o.delete(n);return this}function l(...r){for(const t of r)for(const n of h(t)?[t]:t)o.add(n),e.delete(n);return this}function i(r){return!d(r)&&g(r)}return i.addToIgnoreList=l,i.addToWatchList=f,i.watching=i,a&&i.addToWatchList(a),i}function L(...a){const e=new Set,o=new Set;function g(t){return u.extname(t).toLocaleLowerCase()}function d(t){return e.size===0||e.has(g(t))}function f(t){return o.size!==0&&o.has(g(t))}function l(...t){for(const n of t)for(const s of h(n)?[n]:n){const c=s.startsWith(".")?s.toLocaleLowerCase():"."+s.toLocaleLowerCase();e.add(c),o.delete(c)}return this}function i(...t){for(const n of t)for(const s of h(n)?[n]:n){const c=s.startsWith(".")?s.toLocaleLowerCase():"."+s.toLocaleLowerCase();o.add(c),e.delete(c)}return this}function r(t){return!f(t)&&d(t)}return r.addToIgnoreList=i,r.addToWatchList=l,r.watching=r,a&&r.addToWatchList(a),r}export{S as MakeStringWatcher,L as MakeSuffixWatcher};