@joshfarrant/shortcuts-js
Version:
An iOS 12 Shortcuts creator
29 lines • 888 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/** @ignore */
const itemTypeMap = [{
itemType: 0,
validator: (item) => (typeof item === typeof ''),
}, {
itemType: 1,
validator: (item) => (!Array.isArray(item) && Object(item) === item),
}, {
itemType: 2,
validator: (item) => (Array.isArray(item)),
}, {
itemType: 3,
validator: (item) => (typeof item === typeof 0),
}, {
itemType: 4,
validator: (item) => (typeof item === typeof true),
}];
/** @ignore */
exports.getItemType = (item) => {
// Find the validator that returns true for this item
const match = itemTypeMap.find(({ validator }) => (validator(item)));
if (!match) {
throw new Error('Invalid itemType');
}
return match.itemType;
};
//# sourceMappingURL=getItemType.js.map