UNPKG

@k8ts/instruments

Version:

A collection of utilities and core components for k8ts.

194 lines 8.68 kB
"use strict"; var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for (var i = decorators.length - 1; i >= 0; i--) { var context = {}; for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; for (var p in contextIn.access) context.access[p] = contextIn.access[p]; context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || typeof result !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.unshift(_); } else if (_ = accept(result)) { if (kind === "field") initializers.unshift(_); else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; }; var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { var useValue = arguments.length > 2; for (var i = 0; i < initializers.length; i++) { value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); } return useValue ? value : void 0; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Dest = exports.RefName = exports.Quantity = exports.Verb = exports.Attr = void 0; exports.verb = verb; exports.attr = attr; exports.quantity = quantity; exports.dest = dest; exports.ref = ref; const chalk_1 = __importDefault(require("chalk")); const displayers_1 = require("../displayers"); let Attr = (() => { let _classDecorators = [(0, displayers_1.displayers)({ simple: s => s.text, pretty: attr => chalk_1.default.yellowBright(attr.text) })]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var Attr = class { static { _classThis = this; } static { const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); Attr = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); __runInitializers(_classThis, _classExtraInitializers); } text; constructor(text) { this.text = text; } }; return Attr = _classThis; })(); exports.Attr = Attr; let Verb = (() => { let _classDecorators = [(0, displayers_1.displayers)({ simple: s => s.text, pretty: verb => chalk_1.default.bgGreen.bold.white(` ${verb.text} `) })]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var Verb = class { static { _classThis = this; } static { const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); Verb = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); __runInitializers(_classThis, _classExtraInitializers); } text; constructor(text) { this.text = text; } }; return Verb = _classThis; })(); exports.Verb = Verb; let Quantity = (() => { let _classDecorators = [(0, displayers_1.displayers)({ simple: s => `${s.num} ${s.noun}`, pretty(self) { const { num, noun } = self; const nounForm = num > 1 ? `${noun}s` : noun; return `${chalk_1.default.red(num)} ${chalk_1.default.green(nounForm)}`; } })]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var Quantity = class { static { _classThis = this; } static { const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); Quantity = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); __runInitializers(_classThis, _classExtraInitializers); } num; noun; constructor(num, noun) { this.num = num; this.noun = noun; } }; return Quantity = _classThis; })(); exports.Quantity = Quantity; let RefName = (() => { let _classDecorators = [(0, displayers_1.displayers)({ simple: s => s.name, pretty: refName => chalk_1.default.bgGrey.bold.white(` ${refName.name} `) })]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var RefName = class { static { _classThis = this; } static { const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); RefName = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); __runInitializers(_classThis, _classExtraInitializers); } name; constructor(name) { this.name = name; } }; return RefName = _classThis; })(); exports.RefName = RefName; let Dest = (() => { let _classDecorators = [(0, displayers_1.displayers)({ simple: s => s.text, pretty: dest => chalk_1.default.blueBright(dest.text) })]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var Dest = class { static { _classThis = this; } static { const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); Dest = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); __runInitializers(_classThis, _classExtraInitializers); } text; constructor(text) { this.text = text; } }; return Dest = _classThis; })(); exports.Dest = Dest; function verb(verb) { return new Verb(verb); } function attr(attr) { return new Attr(attr); } function quantity(num, noun) { return new Quantity(num, noun); } function dest(text) { return new Dest(text); } function ref(name) { return new RefName(name); } //# sourceMappingURL=pretty-objects.js.map