UNPKG

spinjs

Version:

[![Join the chat at https://gitter.im/sysgears/spinjs](https://badges.gitter.im/sysgears/spinjs.svg)](https://gitter.im/sysgears/spinjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![npm version](https://badge.fury.io/js/spi

61 lines 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Stack = (function () { function Stack(name) { var stack = []; for (var _i = 1; _i < arguments.length; _i++) { stack[_i - 1] = arguments[_i]; } this.technologies = stack .reduce(function (acc, tech) { if (!tech) { return acc; } else if (tech.constructor === Array) { return acc.concat(tech); } else { return acc.concat(tech.split(':')); } }, []) .filter(function (v, i, a) { return a.indexOf(v) === i; }); if (this.hasAny('server')) { this.platform = 'server'; } else if (this.hasAny('web')) { this.platform = 'web'; } else if (this.hasAny('android')) { this.platform = 'android'; } else if (this.hasAny('ios')) { this.platform = 'ios'; } else { throw new Error("stack should include one of 'server', 'web', 'android', 'ios', stack: " + this.technologies + " for builder " + name); } } Stack.prototype.hasAny = function (technologies) { var array = technologies.constructor === Array ? technologies : [technologies]; for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { var feature = array_1[_i]; if (this.technologies.indexOf(feature) >= 0) { return true; } } return false; }; Stack.prototype.hasAll = function (technologies) { var array = technologies.constructor === Array ? technologies : [technologies]; for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { var feature = array_2[_i]; if (this.technologies.indexOf(feature) < 0) { return false; } } return true; }; return Stack; }()); exports.default = Stack; //# sourceMappingURL=Stack.js.map