flooent
Version:
Fluent interface to provide an expressive syntax for common manipulations.
37 lines (36 loc) • 1.8 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.given = exports.Mappable = exports.Arrayable = exports.Stringable = void 0;
const Arrayable_1 = __importDefault(require("./collections/Arrayable"));
exports.Arrayable = Arrayable_1.default;
const Stringable_1 = __importDefault(require("./collections/Stringable"));
exports.Stringable = Stringable_1.default;
const Mappable_1 = __importDefault(require("./collections/Mappable"));
exports.Mappable = Mappable_1.default;
/**
* Create a flooent string. You have access to [everything from the native String object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String).
*/
function string(value) {
return new Stringable_1.default(value);
}
string.macro = (key, callback) => (Stringable_1.default.prototype[key] = callback);
const array = (value) => Arrayable_1.default.from(value);
array.macro = (key, callback) => (Arrayable_1.default.prototype[key] = callback);
/**
* Executes callback for number of base values' times and returns a flooent array with the result of each iteration.
*/
array.sized = Arrayable_1.default.sized.bind(Arrayable_1.default);
/**
* Create a flooent map. You have access to [everything from the native Map object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).
*/
const map = (value) => new Mappable_1.default(value);
map.macro = (key, callback) => (Mappable_1.default.prototype[key] = callback);
/**
* Create a map from an object
*/
map.fromObject = Mappable_1.default.fromObject.bind(Mappable_1.default);
const given = { string, array, map };
exports.given = given;
;