MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / resolve

Method resolve

tools/common/_hyperscript.iife.js:5749–5778  ·  view source on GitHub ↗
(ctx, { root, from, to, re, count })

Source from the content-addressed store, hash-verified

5747 }
5748 }
5749 resolve(ctx, { root, from, to, re, count }) {
5750 if (this.variant === "first") {
5751 ctx.result = root.slice(0, count);
5752 } else if (this.variant === "last") {
5753 ctx.result = root.slice(-count);
5754 } else if (this.variant === "random") {
5755 if (count == null) {
5756 ctx.result = root[Math.floor(Math.random() * root.length)];
5757 } else {
5758 var copy = Array.from(root);
5759 var result = [];
5760 for (var i = 0; i < count && copy.length > 0; i++) {
5761 var idx = Math.floor(Math.random() * copy.length);
5762 result.push(copy.splice(idx, 1)[0]);
5763 }
5764 ctx.result = result;
5765 }
5766 } else if (this.variant === "range") {
5767 if (this.range.toEnd) to = root.length;
5768 if (!this.range.includeStart) from++;
5769 if (this.range.includeEnd) to++;
5770 if (to == null) to = from + 1;
5771 ctx.result = root.slice(from, to);
5772 } else if (this.variant === "match") {
5773 ctx.result = new RegExp(re, this.flags).exec(root);
5774 } else {
5775 ctx.result = new RegExpIterable(re, this.flags, root);
5776 }
5777 return this.findNext(ctx);
5778 }
5779 };
5780 var FetchCommand = class _FetchCommand extends Command {
5781 static keyword = "fetch";

Callers

nothing calls this directly

Calls 1

findNextMethod · 0.45

Tested by

no test coverage detected