UNPKG

@resin/pinejs

Version:

Pine.js is a sophisticated rules-driven API engine that enables you to define rules in a structured subset of English. Those rules are used in order for Pine.js to generate a database schema and the associated [OData](http://www.odata.org/) API. This make

46 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getMappingFn = exports.settleMapSeries = void 0; const _ = require("lodash"); exports.settleMapSeries = async (a, fn) => { const results = []; for (const p of a) { try { const result = await fn(p); results.push(result); } catch (err) { results.push(ensureError(err)); } } return results; }; const ensureError = (err) => { if (err instanceof Error || _.isError(err)) { return err; } return new Error(err); }; const mapTill = async (a, fn) => { const results = []; for (const p of a) { try { const result = await fn(p); results.push(result); } catch (err) { results.push(ensureError(err)); break; } } return results; }; exports.getMappingFn = (headers) => { if (headers != null && headers.prefer === 'odata.continue-on-error') { return exports.settleMapSeries; } else { return mapTill; } }; //# sourceMappingURL=control-flow.js.map