UNPKG

noflo

Version:

Flow-Based Programming environment for JavaScript

55 lines (54 loc) 1.33 kB
"use strict"; // NoFlo - Flow-Based Programming for JavaScript // (c) 2014-2017 Flowhub UG // NoFlo may be freely distributed under the MIT license // Object.defineProperty(exports, "__esModule", { value: true }); exports.makeAsync = exports.deprecated = exports.isBrowser = void 0; /* eslint-disable no-console, no-undef, */ // Platform detection method /** * @returns {boolean} */ function isBrowser() { if ((typeof process !== 'undefined') && process.execPath && process.execPath.match(/node|iojs/)) { return false; } return true; } exports.isBrowser = isBrowser; // Mechanism for showing API deprecation warnings. By default logs the warnings // but can also be configured to throw instead with the `NOFLO_FATAL_DEPRECATED` // env var. /** * @param {string} message * @returns {void} */ function deprecated(message) { if (isBrowser()) { console.warn(message); return; } if (process.env.NOFLO_FATAL_DEPRECATED) { throw new Error(message); } console.warn(message); } exports.deprecated = deprecated; /** * @param {Function} func * @returns {void} */ function makeAsync(func) { if (isBrowser()) { setTimeout(func, 0); return; } setImmediate(() => { func(); }); } exports.makeAsync = makeAsync;