How to use checkIdentityKeys method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

reactivity.esm-browser.js

Source: reactivity.esm-browser.js Github

copy
1/**
2 * Make a map and return a function for checking if a key
3 * is in that map.
4 * IMPORTANT: all calls of this function must be prefixed with
5 * \/\*#\_\_PURE\_\_\*\/
6 * So that rollup can tree-shake them if necessary.
7 */
8function makeMap(str, expectsLowerCase) {
9    const map = Object.create(null);
10    const list = str.split(',');
11    for (let i = 0; i < list.length; i++) {
12        map[list[i]] = true;
13    }
14    return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
15}
16
17const EMPTY_OBJ =  Object.freeze({})
18    ;
19const extend = Object.assign;
20const hasOwnProperty = Object.prototype.hasOwnProperty;
21const hasOwn = (val, key) => hasOwnProperty.call(val, key);
22const isArray = Array.isArray;
23const isFunction = (val) => typeof val === 'function';
24const isSymbol = (val) => typeof val === 'symbol';
25const isObject = (val) => val !== null && typeof val === 'object';
26const objectToString = Object.prototype.toString;
27const toTypeString = (value) => objectToString.call(value);
28const toRawType = (value) => {
29    return toTypeString(value).slice(8, -1);
30};
31const cacheStringFunction = (fn) => {
32    const cache = Object.create(null);
33    return ((str) => {
34        const hit = cache[str];
35        return hit || (cache[str] = fn(str));
36    });
37};
38const capitalize = cacheStringFunction((str) => {
39    return str.charAt(0).toUpperCase() + str.slice(1);
40});
41// compare whether a value has changed, accounting for NaN.
42const hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue);
43const def = (obj, key, value) => {
44    Object.defineProperty(obj, key, {
45        configurable: true,
46        enumerable: false,
47        value
48    });
49};
50
51const targetMap = new WeakMap();
52const effectStack = [];
53let activeEffect;
54const ITERATE_KEY = Symbol( 'iterate' );
55const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
56function isEffect(fn) {
57    return fn && fn._isEffect === true;
58}
59function effect(fn, options = EMPTY_OBJ) {
60    if (isEffect(fn)) {
61        fn = fn.raw;
62    }
63    const effect = createReactiveEffect(fn, options);
64    if (!options.lazy) {
65        effect();
66    }
67    return effect;
68}
69function stop(effect) {
70    if (effect.active) {
71        cleanup(effect);
72        if (effect.options.onStop) {
73            effect.options.onStop();
74        }
75        effect.active = false;
76    }
77}
78let uid = 0;
79function createReactiveEffect(fn, options) {
80    const effect = function reactiveEffect(...args) {
81        if (!effect.active) {
82            return options.scheduler ? undefined : fn(...args);
83        }
84        if (!effectStack.includes(effect)) {
85            cleanup(effect);
86            try {
87                enableTracking();
88                effectStack.push(effect);
89                activeEffect = effect;
90                return fn(...args);
91            }
92            finally {
93                effectStack.pop();
94                resetTracking();
95                activeEffect = effectStack[effectStack.length - 1];
96            }
97        }
98    };
99    effect.id = uid++;
100    effect._isEffect = true;
101    effect.active = true;
102    effect.raw = fn;
103    effect.deps = [];
104    effect.options = options;
105    return effect;
106}
107function cleanup(effect) {
108    const { deps } = effect;
109    if (deps.length) {
110        for (let i = 0; i < deps.length; i++) {
111            deps[i].delete(effect);
112        }
113        deps.length = 0;
114    }
115}
116let shouldTrack = true;
117const trackStack = [];
118function pauseTracking() {
119    trackStack.push(shouldTrack);
120    shouldTrack = false;
121}
122function enableTracking() {
123    trackStack.push(shouldTrack);
124    shouldTrack = true;
125}
126function resetTracking() {
127    const last = trackStack.pop();
128    shouldTrack = last === undefined ? true : last;
129}
130function track(target, type, key) {
131    if (!shouldTrack || activeEffect === undefined) {
132        return;
133    }
134    let depsMap = targetMap.get(target);
135    if (!depsMap) {
136        targetMap.set(target, (depsMap = new Map()));
137    }
138    let dep = depsMap.get(key);
139    if (!dep) {
140        depsMap.set(key, (dep = new Set()));
141    }
142    if (!dep.has(activeEffect)) {
143        dep.add(activeEffect);
144        activeEffect.deps.push(dep);
145        if ( activeEffect.options.onTrack) {
146            activeEffect.options.onTrack({
147                effect: activeEffect,
148                target,
149                type,
150                key
151            });
152        }
153    }
154}
155function trigger(target, type, key, newValue, oldValue, oldTarget) {
156    const depsMap = targetMap.get(target);
157    if (!depsMap) {
158        // never been tracked
159        return;
160    }
161    const effects = new Set();
162    const computedRunners = new Set();
163    const add = (effectsToAdd) => {
164        if (effectsToAdd) {
165            effectsToAdd.forEach(effect => {
166                if (effect !== activeEffect || !shouldTrack) {
167                    if (effect.options.computed) {
168                        computedRunners.add(effect);
169                    }
170                    else {
171                        effects.add(effect);
172                    }
173                }
174            });
175        }
176    };
177    if (type === "clear" /* CLEAR */) {
178        // collection being cleared
179        // trigger all effects for target
180        depsMap.forEach(add);
181    }
182    else if (key === 'length' && isArray(target)) {
183        depsMap.forEach((dep, key) => {
184            if (key === 'length' || key >= newValue) {
185                add(dep);
186            }
187        });
188    }
189    else {
190        // schedule runs for SET | ADD | DELETE
191        if (key !== void 0) {
192            add(depsMap.get(key));
193        }
194        // also run for iteration key on ADD | DELETE | Map.SET
195        const isAddOrDelete = type === "add" /* ADD */ ||
196            (type === "delete" /* DELETE */ && !isArray(target));
197        if (isAddOrDelete ||
198            (type === "set" /* SET */ && target instanceof Map)) {
199            add(depsMap.get(isArray(target) ? 'length' : ITERATE_KEY));
200        }
201        if (isAddOrDelete && target instanceof Map) {
202            add(depsMap.get(MAP_KEY_ITERATE_KEY));
203        }
204    }
205    const run = (effect) => {
206        if ( effect.options.onTrigger) {
207            effect.options.onTrigger({
208                effect,
209                target,
210                key,
211                type,
212                newValue,
213                oldValue,
214                oldTarget
215            });
216        }
217        if (effect.options.scheduler) {
218            effect.options.scheduler(effect);
219        }
220        else {
221            effect();
222        }
223    };
224    // Important: computed effects must be run first so that computed getters
225    // can be invalidated before any normal effects that depend on them are run.
226    computedRunners.forEach(run);
227    effects.forEach(run);
228}
229
230const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
231    .map(key => Symbol[key])
232    .filter(isSymbol));
233const get = /*#__PURE__*/ createGetter();
234const shallowGet = /*#__PURE__*/ createGetter(false, true);
235const readonlyGet = /*#__PURE__*/ createGetter(true);
236const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
237const arrayInstrumentations = {};
238['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
239    arrayInstrumentations[key] = function (...args) {
240        const arr = toRaw(this);
241        for (let i = 0, l = this.length; i < l; i++) {
242            track(arr, "get" /* GET */, i + '');
243        }
244        // we run the method using the original args first (which may be reactive)
245        const res = arr[key](...args);
246        if (res === -1 || res === false) {
247            // if that didn't work, run it again using raw values.
248            return arr[key](...args.map(toRaw));
249        }
250        else {
251            return res;
252        }
253    };
254});
255function createGetter(isReadonly = false, shallow = false) {
256    return function get(target, key, receiver) {
257        if (key === "__v_isReactive" /* IS_REACTIVE */) {
258            return !isReadonly;
259        }
260        else if (key === "__v_isReadonly" /* IS_READONLY */) {
261            return isReadonly;
262        }
263        else if (key === "__v_raw" /* RAW */ &&
264            receiver ===
265                (isReadonly
266                    ? target["__v_readonly" /* READONLY */]
267                    : target["__v_reactive" /* REACTIVE */])) {
268            return target;
269        }
270        const targetIsArray = isArray(target);
271        if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
272            return Reflect.get(arrayInstrumentations, key, receiver);
273        }
274        const res = Reflect.get(target, key, receiver);
275        if (isSymbol(key)
276            ? builtInSymbols.has(key)
277            : key === `__proto__` || key === `__v_isRef`) {
278            return res;
279        }
280        if (!isReadonly) {
281            track(target, "get" /* GET */, key);
282        }
283        if (shallow) {
284            return res;
285        }
286        if (isRef(res)) {
287            // ref unwrapping, only for Objects, not for Arrays.
288            return targetIsArray ? res : res.value;
289        }
290        if (isObject(res)) {
291            // Convert returned value into a proxy as well. we do the isObject check
292            // here to avoid invalid value warning. Also need to lazy access readonly
293            // and reactive here to avoid circular dependency.
294            return isReadonly ? readonly(res) : reactive(res);
295        }
296        return res;
297    };
298}
299const set = /*#__PURE__*/ createSetter();
300const shallowSet = /*#__PURE__*/ createSetter(true);
301function createSetter(shallow = false) {
302    return function set(target, key, value, receiver) {
303        const oldValue = target[key];
304        if (!shallow) {
305            value = toRaw(value);
306            if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
307                oldValue.value = value;
308                return true;
309            }
310        }
311        const hadKey = hasOwn(target, key);
312        const result = Reflect.set(target, key, value, receiver);
313        // don't trigger if target is something up in the prototype chain of original
314        if (target === toRaw(receiver)) {
315            if (!hadKey) {
316                trigger(target, "add" /* ADD */, key, value);
317            }
318            else if (hasChanged(value, oldValue)) {
319                trigger(target, "set" /* SET */, key, value, oldValue);
320            }
321        }
322        return result;
323    };
324}
325function deleteProperty(target, key) {
326    const hadKey = hasOwn(target, key);
327    const oldValue = target[key];
328    const result = Reflect.deleteProperty(target, key);
329    if (result && hadKey) {
330        trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
331    }
332    return result;
333}
334function has(target, key) {
335    const result = Reflect.has(target, key);
336    track(target, "has" /* HAS */, key);
337    return result;
338}
339function ownKeys(target) {
340    track(target, "iterate" /* ITERATE */, ITERATE_KEY);
341    return Reflect.ownKeys(target);
342}
343const mutableHandlers = {
344    get,
345    set,
346    deleteProperty,
347    has,
348    ownKeys
349};
350const readonlyHandlers = {
351    get: readonlyGet,
352    has,
353    ownKeys,
354    set(target, key) {
355        {
356            console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
357        }
358        return true;
359    },
360    deleteProperty(target, key) {
361        {
362            console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
363        }
364        return true;
365    }
366};
367const shallowReactiveHandlers = extend({}, mutableHandlers, {
368    get: shallowGet,
369    set: shallowSet
370});
371// Props handlers are special in the sense that it should not unwrap top-level
372// refs (in order to allow refs to be explicitly passed down), but should
373// retain the reactivity of the normal readonly object.
374const shallowReadonlyHandlers = extend({}, readonlyHandlers, {
375    get: shallowReadonlyGet
376});
377
378const toReactive = (value) => isObject(value) ? reactive(value) : value;
379const toReadonly = (value) => isObject(value) ? readonly(value) : value;
380const toShallow = (value) => value;
381const getProto = (v) => Reflect.getPrototypeOf(v);
382function get$1(target, key, wrap) {
383    target = toRaw(target);
384    const rawKey = toRaw(key);
385    if (key !== rawKey) {
386        track(target, "get" /* GET */, key);
387    }
388    track(target, "get" /* GET */, rawKey);
389    const { has, get } = getProto(target);
390    if (has.call(target, key)) {
391        return wrap(get.call(target, key));
392    }
393    else if (has.call(target, rawKey)) {
394        return wrap(get.call(target, rawKey));
395    }
396}
397function has$1(key) {
398    const target = toRaw(this);
399    const rawKey = toRaw(key);
400    if (key !== rawKey) {
401        track(target, "has" /* HAS */, key);
402    }
403    track(target, "has" /* HAS */, rawKey);
404    const has = getProto(target).has;
405    return has.call(target, key) || has.call(target, rawKey);
406}
407function size(target) {
408    target = toRaw(target);
409    track(target, "iterate" /* ITERATE */, ITERATE_KEY);
410    return Reflect.get(getProto(target), 'size', target);
411}
412function add(value) {
413    value = toRaw(value);
414    const target = toRaw(this);
415    const proto = getProto(target);
416    const hadKey = proto.has.call(target, value);
417    const result = proto.add.call(target, value);
418    if (!hadKey) {
419        trigger(target, "add" /* ADD */, value, value);
420    }
421    return result;
422}
423function set$1(key, value) {
424    value = toRaw(value);
425    const target = toRaw(this);
426    const { has, get, set } = getProto(target);
427    let hadKey = has.call(target, key);
428    if (!hadKey) {
429        key = toRaw(key);
430        hadKey = has.call(target, key);
431    }
432    else {
433        checkIdentityKeys(target, has, key);
434    }
435    const oldValue = get.call(target, key);
436    const result = set.call(target, key, value);
437    if (!hadKey) {
438        trigger(target, "add" /* ADD */, key, value);
439    }
440    else if (hasChanged(value, oldValue)) {
441        trigger(target, "set" /* SET */, key, value, oldValue);
442    }
443    return result;
444}
445function deleteEntry(key) {
446    const target = toRaw(this);
447    const { has, get, delete: del } = getProto(target);
448    let hadKey = has.call(target, key);
449    if (!hadKey) {
450        key = toRaw(key);
451        hadKey = has.call(target, key);
452    }
453    else {
454        checkIdentityKeys(target, has, key);
455    }
456    const oldValue = get ? get.call(target, key) : undefined;
457    // forward the operation before queueing reactions
458    const result = del.call(target, key);
459    if (hadKey) {
460        trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
461    }
462    return result;
463}
464function clear() {
465    const target = toRaw(this);
466    const hadItems = target.size !== 0;
467    const oldTarget =  target instanceof Map
468            ? new Map(target)
469            : new Set(target)
470        ;
471    // forward the operation before queueing reactions
472    const result = getProto(target).clear.call(target);
473    if (hadItems) {
474        trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget);
475    }
476    return result;
477}
478function createForEach(isReadonly, shallow) {
479    return function forEach(callback, thisArg) {
480        const observed = this;
481        const target = toRaw(observed);
482        const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive;
483        !isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY);
484        // important: create sure the callback is
485        // 1. invoked with the reactive map as `this` and 3rd arg
486        // 2. the value received should be a corresponding reactive/readonly.
487        function wrappedCallback(value, key) {
488            return callback.call(thisArg, wrap(value), wrap(key), observed);
489        }
490        return getProto(target).forEach.call(target, wrappedCallback);
491    };
492}
493function createIterableMethod(method, isReadonly, shallow) {
494    return function (...args) {
495        const target = toRaw(this);
496        const isMap = target instanceof Map;
497        const isPair = method === 'entries' || (method === Symbol.iterator && isMap);
498        const isKeyOnly = method === 'keys' && isMap;
499        const innerIterator = getProto(target)[method].apply(target, args);
500        const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive;
501        !isReadonly &&
502            track(target, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
503        // return a wrapped iterator which returns observed versions of the
504        // values emitted from the real iterator
505        return {
506            // iterator protocol
507            next() {
508                const { value, done } = innerIterator.next();
509                return done
510                    ? { value, done }
511                    : {
512                        value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
513                        done
514                    };
515            },
516            // iterable protocol
517            [Symbol.iterator]() {
518                return this;
519            }
520        };
521    };
522}
523function createReadonlyMethod(type) {
524    return function (...args) {
525        {
526            const key = args[0] ? `on key "${args[0]}" ` : ``;
527            console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
528        }
529        return type === "delete" /* DELETE */ ? false : this;
530    };
531}
532const mutableInstrumentations = {
533    get(key) {
534        return get$1(this, key, toReactive);
535    },
536    get size() {
537        return size(this);
538    },
539    has: has$1,
540    add,
541    set: set$1,
542    delete: deleteEntry,
543    clear,
544    forEach: createForEach(false, false)
545};
546const shallowInstrumentations = {
547    get(key) {
548        return get$1(this, key, toShallow);
549    },
550    get size() {
551        return size(this);
552    },
553    has: has$1,
554    add,
555    set: set$1,
556    delete: deleteEntry,
557    clear,
558    forEach: createForEach(false, true)
559};
560const readonlyInstrumentations = {
561    get(key) {
562        return get$1(this, key, toReadonly);
563    },
564    get size() {
565        return size(this);
566    },
567    has: has$1,
568    add: createReadonlyMethod("add" /* ADD */),
569    set: createReadonlyMethod("set" /* SET */),
570    delete: createReadonlyMethod("delete" /* DELETE */),
571    clear: createReadonlyMethod("clear" /* CLEAR */),
572    forEach: createForEach(true, false)
573};
574const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
575iteratorMethods.forEach(method => {
576    mutableInstrumentations[method] = createIterableMethod(method, false, false);
577    readonlyInstrumentations[method] = createIterableMethod(method, true, false);
578    shallowInstrumentations[method] = createIterableMethod(method, false, true);
579});
580function createInstrumentationGetter(isReadonly, shallow) {
581    const instrumentations = shallow
582        ? shallowInstrumentations
583        : isReadonly
584            ? readonlyInstrumentations
585            : mutableInstrumentations;
586    return (target, key, receiver) => {
587        if (key === "__v_isReactive" /* IS_REACTIVE */) {
588            return !isReadonly;
589        }
590        else if (key === "__v_isReadonly" /* IS_READONLY */) {
591            return isReadonly;
592        }
593        else if (key === "__v_raw" /* RAW */) {
594            return target;
595        }
596        return Reflect.get(hasOwn(instrumentations, key) && key in target
597            ? instrumentations
598            : target, key, receiver);
599    };
600}
601const mutableCollectionHandlers = {
602    get: createInstrumentationGetter(false, false)
603};
604const shallowCollectionHandlers = {
605    get: createInstrumentationGetter(false, true)
606};
607const readonlyCollectionHandlers = {
608    get: createInstrumentationGetter(true, false)
609};
610function checkIdentityKeys(target, has, key) {
611    const rawKey = toRaw(key);
612    if (rawKey !== key && has.call(target, rawKey)) {
613        const type = toRawType(target);
614        console.warn(`Reactive ${type} contains both the raw and reactive ` +
615            `versions of the same object${type === `Map` ? `as keys` : ``}, ` +
616            `which can lead to inconsistencies. ` +
617            `Avoid differentiating between the raw and reactive versions ` +
618            `of an object and only use the reactive version if possible.`);
619    }
620}
621
622const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]);
623const isObservableType = /*#__PURE__*/ makeMap('Object,Array,Map,Set,WeakMap,WeakSet');
624const canObserve = (value) => {
625    return (!value["__v_skip" /* SKIP */] &&
626        isObservableType(toRawType(value)) &&
627        !Object.isFrozen(value));
628};
629function reactive(target) {
630    // if trying to observe a readonly proxy, return the readonly version.
631    if (target && target["__v_isReadonly" /* IS_READONLY */]) {
632        return target;
633    }
634    return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
635}
636// Return a reactive-copy of the original object, where only the root level
637// properties are reactive, and does NOT unwrap refs nor recursively convert
638// returned properties.
639function shallowReactive(target) {
640    return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
641}
642function readonly(target) {
643    return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
644}
645// Return a reactive-copy of the original object, where only the root level
646// properties are readonly, and does NOT unwrap refs nor recursively convert
647// returned properties.
648// This is used for creating the props proxy object for stateful components.
649function shallowReadonly(target) {
650    return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
651}
652function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) {
653    if (!isObject(target)) {
654        {
655            console.warn(`value cannot be made reactive: ${String(target)}`);
656        }
657        return target;
658    }
659    // target is already a Proxy, return it.
660    // exception: calling readonly() on a reactive object
661    if (target["__v_raw" /* RAW */] &&
662        !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) {
663        return target;
664    }
665    // target already has corresponding Proxy
666    if (hasOwn(target, isReadonly ? "__v_readonly" /* READONLY */ : "__v_reactive" /* REACTIVE */)) {
667        return isReadonly
668            ? target["__v_readonly" /* READONLY */]
669            : target["__v_reactive" /* REACTIVE */];
670    }
671    // only a whitelist of value types can be observed.
672    if (!canObserve(target)) {
673        return target;
674    }
675    const observed = new Proxy(target, collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers);
676    def(target, isReadonly ? "__v_readonly" /* READONLY */ : "__v_reactive" /* REACTIVE */, observed);
677    return observed;
678}
679function isReactive(value) {
680    if (isReadonly(value)) {
681        return isReactive(value["__v_raw" /* RAW */]);
682    }
683    return !!(value && value["__v_isReactive" /* IS_REACTIVE */]);
684}
685function isReadonly(value) {
686    return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
687}
688function isProxy(value) {
689    return isReactive(value) || isReadonly(value);
690}
691function toRaw(observed) {
692    return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
693}
694function markRaw(value) {
695    def(value, "__v_skip" /* SKIP */, true);
696    return value;
697}
698
699const convert = (val) => isObject(val) ? reactive(val) : val;
700function isRef(r) {
701    return r ? r.__v_isRef === true : false;
702}
703function ref(value) {
704    return createRef(value);
705}
706function shallowRef(value) {
707    return createRef(value, true);
708}
709function createRef(rawValue, shallow = false) {
710    if (isRef(rawValue)) {
711        return rawValue;
712    }
713    let value = shallow ? rawValue : convert(rawValue);
714    const r = {
715        __v_isRef: true,
716        get value() {
717            track(r, "get" /* GET */, 'value');
718            return value;
719        },
720        set value(newVal) {
721            if (hasChanged(toRaw(newVal), rawValue)) {
722                rawValue = newVal;
723                value = shallow ? newVal : convert(newVal);
724                trigger(r, "set" /* SET */, 'value',  { newValue: newVal } );
725            }
726        }
727    };
728    return r;
729}
730function triggerRef(ref) {
731    trigger(ref, "set" /* SET */, 'value',  { newValue: ref.value } );
732}
733function unref(ref) {
734    return isRef(ref) ? ref.value : ref;
735}
736function customRef(factory) {
737    const { get, set } = factory(() => track(r, "get" /* GET */, 'value'), () => trigger(r, "set" /* SET */, 'value'));
738    const r = {
739        __v_isRef: true,
740        get value() {
741            return get();
742        },
743        set value(v) {
744            set(v);
745        }
746    };
747    return r;
748}
749function toRefs(object) {
750    if ( !isProxy(object)) {
751        console.warn(`toRefs() expects a reactive object but received a plain one.`);
752    }
753    const ret = {};
754    for (const key in object) {
755        ret[key] = toRef(object, key);
756    }
757    return ret;
758}
759function toRef(object, key) {
760    return {
761        __v_isRef: true,
762        get value() {
763            return object[key];
764        },
765        set value(newVal) {
766            object[key] = newVal;
767        }
768    };
769}
770
771function computed(getterOrOptions) {
772    let getter;
773    let setter;
774    if (isFunction(getterOrOptions)) {
775        getter = getterOrOptions;
776        setter =  () => {
777                console.warn('Write operation failed: computed value is readonly');
778            }
779            ;
780    }
781    else {
782        getter = getterOrOptions.get;
783        setter = getterOrOptions.set;
784    }
785    let dirty = true;
786    let value;
787    let computed;
788    const runner = effect(getter, {
789        lazy: true,
790        // mark effect as computed so that it gets priority during trigger
791        computed: true,
792        scheduler: () => {
793            if (!dirty) {
794                dirty = true;
795                trigger(computed, "set" /* SET */, 'value');
796            }
797        }
798    });
799    computed = {
800        __v_isRef: true,
801        // expose effect so computed can be stopped
802        effect: runner,
803        get value() {
804            if (dirty) {
805                value = runner();
806                dirty = false;
807            }
808            track(computed, "get" /* GET */, 'value');
809            return value;
810        },
811        set value(newValue) {
812            setter(newValue);
813        }
814    };
815    return computed;
816}
817
818export { ITERATE_KEY, computed, customRef, effect, enableTracking, isProxy, isReactive, isReadonly, isRef, markRaw, pauseTracking, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, track, trigger, triggerRef, unref };
819
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Playwright Internal on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)