MCPcopy Create free account
hub / github.com/Nynxz/ComfyUI-IdeogramHelper / createIterableMethod

Function createIterableMethod

web/main.js:1203–1232  ·  view source on GitHub ↗
(method, isReadonly2, isShallow2)

Source from the content-addressed store, hash-verified

1201const toShallow = (value) => value;
1202const getProto = (v) => Reflect.getPrototypeOf(v);
1203function createIterableMethod(method, isReadonly2, isShallow2) {
1204 return function(...args) {
1205 const target = this["__v_raw"];
1206 const rawTarget = /* @__PURE__ */ toRaw(target);
1207 const targetIsMap = isMap(rawTarget);
1208 const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
1209 const isKeyOnly = method === "keys" && targetIsMap;
1210 const innerIterator = target[method](...args);
1211 const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
1212 !isReadonly2 && track(
1213 rawTarget,
1214 "iterate",
1215 isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
1216 );
1217 return extend(
1218 // inheriting all iterator properties
1219 Object.create(innerIterator),
1220 {
1221 // iterator protocol
1222 next() {
1223 const { value, done } = innerIterator.next();
1224 return done ? { value, done } : {
1225 value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1226 done
1227 };
1228 }
1229 }
1230 );
1231 };
1232}
1233function createReadonlyMethod(type) {
1234 return function(...args) {
1235 return type === "delete" ? false : type === "clear" ? void 0 : this;

Callers 1

createInstrumentationsFunction · 0.85

Calls 3

toRawFunction · 0.85
isMapFunction · 0.85
trackFunction · 0.85

Tested by

no test coverage detected