From 35526cc4d3d74f08b3be4637a1934885d2ed7ab6 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Thu, 4 Apr 2019 00:16:04 +0700 Subject: [PATCH] Move select helper --- index.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index c223f8d..ef40dd2 100755 --- a/index.js +++ b/index.js @@ -4,6 +4,16 @@ const os = require('os') const fs = require('fs') const path = require('path') +const skip = Symbol('skip') +global.select = function select(cb) { + return json => { + if (!cb(json)) { + throw skip + } + return json + } +} + try { require(path.join(os.homedir(), '.fxrc')) // Should be required before config.js usage. } catch (err) { @@ -43,8 +53,6 @@ const usage = ` const {stdin, stdout, stderr} = process const args = process.argv.slice(2) -const skip = Symbol('skip') -global.select = select void function main() { @@ -121,13 +129,3 @@ function apply(json) { console.log(text) } } - - -function select(cb) { - return json => { - if (!cb(json)) { - throw skip - } - return json - } -}