tiny-fsearch
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -21,3 +21,4 @@ "use strict"; | ||
const predicate = options_1.IQueryOptions.Resolve.predicate(input, params); | ||
return Binding.raw().synchronous(sources, predicate); | ||
const alternatives = options_1.IQueryOptions.Resolve.alternatives(sources, params); | ||
return Binding.raw().synchronous(sources, predicate, alternatives); | ||
}; | ||
@@ -32,5 +33,6 @@ Binding.stream = (source, input, options) => { | ||
const predicate = options_1.IQueryOptions.Resolve.predicate(input, params); | ||
return new (Binding.raw().Generator)(sources, predicate); | ||
const alternatives = options_1.IQueryOptions.Resolve.alternatives(sources, params); | ||
return new (Binding.raw().Generator)(sources, predicate, alternatives); | ||
}; | ||
Binding.raw = () => (0, bindings_1.default)('fsearch'); | ||
})(Binding = exports.Binding || (exports.Binding = {})); |
@@ -15,2 +15,3 @@ "use strict"; | ||
matchWholeWord: false, | ||
alternatives: {}, | ||
}; | ||
@@ -41,3 +42,8 @@ })(IQueryOptions = exports.IQueryOptions || (exports.IQueryOptions = {})); | ||
}; | ||
Resolve.alternatives = (sources, { alternatives: _ }) => { | ||
for (const key in Object.keys(_)) | ||
!sources.includes(key) && delete _[key]; | ||
return _; | ||
}; | ||
})(Resolve = IQueryOptions.Resolve || (IQueryOptions.Resolve = {})); | ||
})(IQueryOptions = exports.IQueryOptions || (exports.IQueryOptions = {})); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -8,8 +31,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const __1 = __importDefault(require("..")); | ||
(0, ava_1.default)('Query Async - defaulted "hello"', async (_) => { | ||
const stream = __1.default.stream('lib', 'hello'); | ||
const Constants = __importStar(require("../utils/constants")); | ||
(0, ava_1.default)(`Query Async - defaulted "${Constants.TEST_PREDICATE}"`, async (_) => { | ||
const stream = __1.default.stream('lib', Constants.TEST_PREDICATE); | ||
let counter = 0; | ||
for await (const matches of stream) | ||
counter += matches.length; | ||
_.is(counter, 4, 'Invalid result count'); | ||
_.is(counter, Constants.TEST_EXPECTED_LENGTH, 'Invalid result count'); | ||
}); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -8,5 +31,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const __1 = __importDefault(require("..")); | ||
(0, ava_1.default)('Query Sync - defaulted "hello"', (_) => { | ||
const results = __1.default.sync('lib', 'hello'); | ||
_.is(results.length, 4, 'Invalid result count'); | ||
const Constants = __importStar(require("../utils/constants")); | ||
(0, ava_1.default)(`Query Sync - defaulted "${Constants.TEST_PREDICATE}"`, (_) => { | ||
const results = __1.default.sync('lib', Constants.TEST_PREDICATE); | ||
_.is(results.length, Constants.TEST_EXPECTED_LENGTH, 'Invalid result count'); | ||
}); |
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { IQueryMatch } from './types'; | ||
@@ -8,5 +10,5 @@ import { IQueryOptions } from './options'; | ||
interface IRaw { | ||
synchronous: (sources: string[], predicate: string) => IQueryMatch[]; | ||
synchronous: (sources: string[], predicate: string, alternatives: NodeJS.Dict<Buffer>) => IQueryMatch[]; | ||
Generator: { | ||
new (sources: string[], predicate: string): IGenerator; | ||
new (sources: string[], predicate: string, alternatives: NodeJS.Dict<Buffer>): IGenerator; | ||
}; | ||
@@ -13,0 +15,0 @@ } |
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
export interface IQueryOptions { | ||
@@ -5,2 +7,3 @@ readonly exclude: string[]; | ||
readonly matchWholeWord: boolean; | ||
readonly alternatives: NodeJS.Dict<Buffer>; | ||
} | ||
@@ -13,2 +16,3 @@ export declare namespace IQueryOptions { | ||
const sources: (source: string, { exclude }: IQueryOptions) => string[]; | ||
const alternatives: (sources: string[], { alternatives: _ }: IQueryOptions) => NodeJS.Dict<Buffer>; | ||
} |
{ | ||
"name": "tiny-fsearch", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A small and versatile find-in-file/search library.", | ||
@@ -20,2 +20,3 @@ "main": "dist/index.js", | ||
"src/**/*", | ||
"tools/**/*", | ||
"binding.gyp" | ||
@@ -22,0 +23,0 @@ ], |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
38568
31
371
3