geninq
Version:
A JavaScript version of the Linq library for Generators
41 lines (40 loc) • 1.8 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
require("./geninq");
(0, utils_1.Build)("sequence_equal", function (that, comparitor = (a, b) => a === b) {
that = Array.isArray(that) ? that.geninq() : that;
let this_part = this.next();
let that_part = that.next();
while (!this_part.done || !that_part.done) {
if (!comparitor(this_part.value, that_part.value)) {
return false;
}
this_part = this.next();
that_part = that.next();
}
return true;
}, function (that, comparitor = (a, b) => a === b) {
return __awaiter(this, void 0, void 0, function* () {
that = Array.isArray(that) ? that.geninq() : that;
let this_part = yield this.next();
let that_part = yield that.next();
while (!this_part.done || !that_part.done) {
if (!comparitor(this_part.value, that_part.value)) {
return false;
}
this_part = yield this.next();
that_part = yield that.next();
}
return true;
});
});