How to use isProxy method in Playwright Internal

Best JavaScript code snippet using playwright-internal

dummyData.js

Source:dummyData.js Github

copy

Full Screen

1const dummyGroups = [2 [3 "138204",4 {5 group: {6 isProxy: true,7 options: {},8 name: "Gruppe 1",9 createdAt: 1503241136,10 instanceId: 138204,11 onOff: false,12 dimmer: 0,13 deviceIDs: [65537],14 sceneId: 203167,15 groupType: 0,16 },17 scenes: {18 "203167": {19 isProxy: true,20 options: {},21 name: "RELAX",22 createdAt: 1503241136,23 instanceId: 203167,24 isActive: false,25 isPredefined: true,26 lightSettings: [27 {28 isProxy: true,29 options: {},30 name: "",31 createdAt: 0,32 instanceId: 65537,33 color: "f1e0b5",34 hue: 0,35 saturation: 0,36 colorX: 0,37 colorY: 0,38 colorTemperature: 0,39 dimmer: 9.8,40 onOff: true,41 },42 ],43 sceneIndex: 1,44 useCurrentLightSettings: false,45 },46 "217570": {47 isProxy: true,48 options: {},49 name: "EVERYDAY",50 createdAt: 1503241136,51 instanceId: 217570,52 isActive: false,53 isPredefined: true,54 lightSettings: [55 {56 isProxy: true,57 options: {},58 name: "",59 createdAt: 0,60 instanceId: 65537,61 color: "f1e0b5",62 hue: 0,63 saturation: 0,64 colorX: 0,65 colorY: 0,66 colorTemperature: 0,67 dimmer: 79.9,68 onOff: true,69 },70 ],71 sceneIndex: 0,72 useCurrentLightSettings: false,73 },74 "225993": {75 isProxy: true,76 options: {},77 name: "FOCUS",78 createdAt: 1503241136,79 instanceId: 225993,80 isActive: false,81 isPredefined: true,82 lightSettings: [83 {84 isProxy: true,85 options: {},86 name: "",87 createdAt: 0,88 instanceId: 65537,89 color: "f1e0b5",90 hue: 0,91 saturation: 0,92 colorX: 0,93 colorY: 0,94 colorTemperature: 0,95 dimmer: 100,96 onOff: true,97 },98 ],99 sceneIndex: 2,100 useCurrentLightSettings: false,101 },102 },103 },104 ],105 [106 "154125",107 {108 group: {109 isProxy: true,110 options: {},111 name: "Group 2",112 createdAt: 1504795182,113 instanceId: 154125,114 onOff: false,115 dimmer: 0,116 deviceIDs: [65542],117 sceneId: 215618,118 groupType: 0,119 },120 scenes: {121 "199636": {122 isProxy: true,123 options: {},124 name: "RELAX",125 createdAt: 1504795182,126 instanceId: 199636,127 isActive: false,128 isPredefined: true,129 lightSettings: [],130 sceneIndex: 1,131 useCurrentLightSettings: false,132 },133 "215618": {134 isProxy: true,135 options: {},136 name: "EVERYDAY",137 createdAt: 1504795182,138 instanceId: 215618,139 isActive: false,140 isPredefined: true,141 lightSettings: [],142 sceneIndex: 0,143 useCurrentLightSettings: false,144 },145 "223800": {146 isProxy: true,147 options: {},148 name: "FOCUS",149 createdAt: 1504795182,150 instanceId: 223800,151 isActive: false,152 isPredefined: true,153 lightSettings: [],154 sceneIndex: 2,155 useCurrentLightSettings: false,156 },157 },158 },159 ],160 [161 "158564",162 {163 group: {164 isProxy: true,165 options: {},166 name: "Group 3",167 createdAt: 1504795450,168 instanceId: 158564,169 onOff: false,170 dimmer: 0,171 deviceIDs: [65543, 65539, 65541, 65540],172 sceneId: 225994,173 groupType: 0,174 },175 scenes: {176 "203571": {177 isProxy: true,178 options: {},179 name: "RELAX",180 createdAt: 1504795450,181 instanceId: 203571,182 isActive: false,183 isPredefined: true,184 lightSettings: [185 {186 isProxy: true,187 options: {},188 name: "",189 createdAt: 0,190 instanceId: 65539,191 color: "f1e0b5",192 hue: 0,193 saturation: 0,194 colorX: 0,195 colorY: 0,196 colorTemperature: 0,197 dimmer: 9.8,198 onOff: true,199 },200 {201 isProxy: true,202 options: {},203 name: "",204 createdAt: 0,205 instanceId: 65541,206 color: "f1e0b5",207 hue: 0,208 saturation: 0,209 colorX: 0,210 colorY: 0,211 colorTemperature: 0,212 dimmer: 9.8,213 onOff: true,214 },215 {216 isProxy: true,217 options: {},218 name: "",219 createdAt: 0,220 instanceId: 65540,221 color: "f1e0b5",222 hue: 0,223 saturation: 0,224 colorX: 0,225 colorY: 0,226 colorTemperature: 0,227 dimmer: 9.8,228 onOff: true,229 },230 ],231 sceneIndex: 1,232 useCurrentLightSettings: false,233 },234 "205876": {235 isProxy: true,236 options: {},237 name: "EVERYDAY",238 createdAt: 1504795450,239 instanceId: 205876,240 isActive: false,241 isPredefined: true,242 lightSettings: [243 {244 isProxy: true,245 options: {},246 name: "",247 createdAt: 0,248 instanceId: 65539,249 color: "f1e0b5",250 hue: 0,251 saturation: 0,252 colorX: 0,253 colorY: 0,254 colorTemperature: 0,255 dimmer: 79.9,256 onOff: true,257 },258 {259 isProxy: true,260 options: {},261 name: "",262 createdAt: 0,263 instanceId: 65541,264 color: "f1e0b5",265 hue: 0,266 saturation: 0,267 colorX: 0,268 colorY: 0,269 colorTemperature: 0,270 dimmer: 79.9,271 onOff: true,272 },273 {274 isProxy: true,275 options: {},276 name: "",277 createdAt: 0,278 instanceId: 65540,279 color: "f1e0b5",280 hue: 0,281 saturation: 0,282 colorX: 0,283 colorY: 0,284 colorTemperature: 0,285 dimmer: 79.9,286 onOff: true,287 },288 ],289 sceneIndex: 0,290 useCurrentLightSettings: false,291 },292 "221759": {293 isProxy: true,294 options: {},295 name: "FOCUS",296 createdAt: 1504795450,297 instanceId: 221759,298 isActive: false,299 isPredefined: true,300 lightSettings: [301 {302 isProxy: true,303 options: {},304 name: "",305 createdAt: 0,306 instanceId: 65539,307 color: "f1e0b5",308 hue: 0,309 saturation: 0,310 colorX: 0,311 colorY: 0,312 colorTemperature: 0,313 dimmer: 100,314 onOff: true,315 },316 {317 isProxy: true,318 options: {},319 name: "",320 createdAt: 0,321 instanceId: 65541,322 color: "f1e0b5",323 hue: 0,324 saturation: 0,325 colorX: 0,326 colorY: 0,327 colorTemperature: 0,328 dimmer: 100,329 onOff: true,330 },331 {332 isProxy: true,333 options: {},334 name: "",335 createdAt: 0,336 instanceId: 65540,337 color: "f1e0b5",338 hue: 0,339 saturation: 0,340 colorX: 0,341 colorY: 0,342 colorTemperature: 0,343 dimmer: 100,344 onOff: true,345 },346 ],347 sceneIndex: 2,348 useCurrentLightSettings: false,349 },350 "225994": {351 isProxy: true,352 options: {},353 name: "Lidt lys",354 createdAt: 1510264781,355 instanceId: 225994,356 isActive: false,357 isPredefined: false,358 lightSettings: [359 {360 isProxy: true,361 options: {},362 name: "",363 createdAt: 0,364 instanceId: 65539,365 color: "f1e0b5",366 hue: 0,367 saturation: 0,368 colorX: 0,369 colorY: 0,370 colorTemperature: 0,371 dimmer: 2,372 onOff: false,373 },374 {375 isProxy: true,376 options: {},377 name: "",378 createdAt: 0,379 instanceId: 65541,380 color: "f1e0b5",381 hue: 0,382 saturation: 0,383 colorX: 0,384 colorY: 0,385 colorTemperature: 0,386 dimmer: 2,387 onOff: false,388 },389 {390 isProxy: true,391 options: {},392 name: "",393 createdAt: 0,394 instanceId: 65540,395 color: "f1e0b5",396 hue: 0,397 saturation: 0,398 colorX: 0,399 colorY: 0,400 colorTemperature: 0,401 dimmer: 0.8,402 onOff: true,403 },404 ],405 sceneIndex: 3,406 useCurrentLightSettings: false,407 },408 "225995": {409 isProxy: true,410 options: {},411 name: "mellem lys",412 createdAt: 1520712390,413 instanceId: 225995,414 isActive: false,415 isPredefined: false,416 lightSettings: [417 {418 isProxy: true,419 options: {},420 name: "",421 createdAt: 0,422 instanceId: 65539,423 color: "f1e0b5",424 hue: 0,425 saturation: 0,426 colorX: 0,427 colorY: 0,428 colorTemperature: 0,429 dimmer: 0.8,430 onOff: true,431 },432 {433 isProxy: true,434 options: {},435 name: "",436 createdAt: 0,437 instanceId: 65541,438 color: "f1e0b5",439 hue: 0,440 saturation: 0,441 colorX: 0,442 colorY: 0,443 colorTemperature: 0,444 dimmer: 7.9,445 onOff: false,446 },447 {448 isProxy: true,449 options: {},450 name: "",451 createdAt: 0,452 instanceId: 65540,453 color: "f1e0b5",454 hue: 0,455 saturation: 0,456 colorX: 0,457 colorY: 0,458 colorTemperature: 0,459 dimmer: 0.8,460 onOff: true,461 },462 ],463 sceneIndex: 4,464 useCurrentLightSettings: false,465 },466 "225996": {467 isProxy: true,468 options: {},469 name: "Alle 1pct",470 createdAt: 1520712436,471 instanceId: 225996,472 isActive: false,473 isPredefined: false,474 lightSettings: [475 {476 isProxy: true,477 options: {},478 name: "",479 createdAt: 0,480 instanceId: 65539,481 color: "f1e0b5",482 hue: 0,483 saturation: 0,484 colorX: 0,485 colorY: 0,486 colorTemperature: 0,487 dimmer: 0.8,488 onOff: true,489 },490 {491 isProxy: true,492 options: {},493 name: "",494 createdAt: 0,495 instanceId: 65541,496 color: "f1e0b5",497 hue: 0,498 saturation: 0,499 colorX: 0,500 colorY: 0,501 colorTemperature: 0,502 dimmer: 0.8,503 onOff: true,504 },505 {506 isProxy: true,507 options: {},508 name: "",509 createdAt: 0,510 instanceId: 65540,511 color: "f1e0b5",512 hue: 0,513 saturation: 0,514 colorX: 0,515 colorY: 0,516 colorTemperature: 0,517 dimmer: 0.8,518 onOff: true,519 },520 ],521 sceneIndex: 5,522 useCurrentLightSettings: false,523 },524 "225997": {525 isProxy: true,526 options: {},527 name: "sluk alt",528 createdAt: 1520712514,529 instanceId: 225997,530 isActive: false,531 isPredefined: false,532 lightSettings: [533 {534 isProxy: true,535 options: {},536 name: "",537 createdAt: 0,538 instanceId: 65539,539 color: "f1e0b5",540 hue: 0,541 saturation: 0,542 colorX: 0,543 colorY: 0,544 colorTemperature: 0,545 dimmer: 2,546 onOff: false,547 },548 {549 isProxy: true,550 options: {},551 name: "",552 createdAt: 0,553 instanceId: 65541,554 color: "f1e0b5",555 hue: 0,556 saturation: 0,557 colorX: 0,558 colorY: 0,559 colorTemperature: 0,560 dimmer: 2,561 onOff: false,562 },563 {564 isProxy: true,565 options: {},566 name: "",567 createdAt: 0,568 instanceId: 65540,569 color: "f1e0b5",570 hue: 0,571 saturation: 0,572 colorX: 0,573 colorY: 0,574 colorTemperature: 0,575 dimmer: 0.8,576 onOff: false,577 },578 ],579 sceneIndex: 6,580 useCurrentLightSettings: false,581 },582 },583 },584 ],585 [586 "184825",587 {588 group: {589 isProxy: true,590 options: {},591 name: "Group 4",592 createdAt: 1503242162,593 instanceId: 184825,594 onOff: false,595 dimmer: 0,596 deviceIDs: [65536, 65538],597 sceneId: 204011,598 groupType: 0,599 },600 scenes: {601 "201802": {602 isProxy: true,603 options: {},604 name: "RELAX",605 createdAt: 1503242162,606 instanceId: 201802,607 isActive: false,608 isPredefined: true,609 lightSettings: [610 {611 isProxy: true,612 options: {},613 name: "",614 createdAt: 0,615 instanceId: 65538,616 color: "f1e0b5",617 hue: 0,618 saturation: 0,619 colorX: 0,620 colorY: 0,621 colorTemperature: 0,622 dimmer: 9.8,623 onOff: true,624 },625 ],626 sceneIndex: 1,627 useCurrentLightSettings: false,628 },629 "203844": {630 isProxy: true,631 options: {},632 name: "FOCUS",633 createdAt: 1503242162,634 instanceId: 203844,635 isActive: false,636 isPredefined: true,637 lightSettings: [638 {639 isProxy: true,640 options: {},641 name: "",642 createdAt: 0,643 instanceId: 65538,644 color: "f1e0b5",645 hue: 0,646 saturation: 0,647 colorX: 0,648 colorY: 0,649 colorTemperature: 0,650 dimmer: 100,651 onOff: true,652 },653 ],654 sceneIndex: 2,655 useCurrentLightSettings: false,656 },657 "204011": {658 isProxy: true,659 options: {},660 name: "EVERYDAY",661 createdAt: 1503242162,662 instanceId: 204011,663 isActive: false,664 isPredefined: true,665 lightSettings: [666 {667 isProxy: true,668 options: {},669 name: "",670 createdAt: 0,671 instanceId: 65538,672 color: "f1e0b5",673 hue: 0,674 saturation: 0,675 colorX: 0,676 colorY: 0,677 colorTemperature: 0,678 dimmer: 79.9,679 onOff: true,680 },681 ],682 sceneIndex: 0,683 useCurrentLightSettings: false,684 },685 },686 },687 ],688];689const dummyDevices = [690 [691 "65536",692 {693 isProxy: true,694 options: {},695 name: "Group 4.Remote",696 createdAt: 1503242154,697 instanceId: 65536,698 type: 0,699 alive: true,700 lastSeen: 1538666004,701 otaUpdateState: 1,702 deviceInfo: {703 isProxy: true,704 options: {},705 firmwareVersion: "1.2.214",706 manufacturer: "IKEA of Sweden",707 modelNumber: "TRADFRI remote control",708 power: 3,709 serialNumber: "",710 battery: 11,711 },712 switchList: [713 {714 isProxy: true,715 options: {},716 name: "",717 createdAt: 0,718 instanceId: 0,719 },720 ],721 },722 ],723 [724 "65537",725 {726 isProxy: true,727 options: {},728 name: "Bulb.E27WS",729 createdAt: 1503241192,730 instanceId: 65537,731 type: 2,732 alive: true,733 lastSeen: 1564945153,734 otaUpdateState: 0,735 deviceInfo: {736 isProxy: true,737 options: {},738 firmwareVersion: "1.2.217",739 manufacturer: "IKEA of Sweden",740 modelNumber: "TRADFRI bulb E27 WS opal 980lm",741 power: 1,742 serialNumber: "",743 },744 lightList: [745 {746 onOff: false,747 dimmer: 9.8,748 color: "f1e0b5",749 transitionTime: 0.5,750 },751 ],752 },753 ],754 [755 "65538",756 {757 isProxy: true,758 options: {},759 name: "Group 4.Bulb.E27WS",760 createdAt: 1503241942,761 instanceId: 65538,762 type: 2,763 alive: false,764 lastSeen: 1564982124,765 otaUpdateState: 0,766 deviceInfo: {767 isProxy: true,768 options: {},769 firmwareVersion: "1.2.217",770 manufacturer: "IKEA of Sweden",771 modelNumber: "TRADFRI bulb E27 WS opal 980lm",772 power: 1,773 serialNumber: "",774 },775 lightList: [776 {777 onOff: false,778 dimmer: 0.8,779 color: "f1e0b5",780 colorTemperature: 100,781 transitionTime: 0.5,782 },783 ],784 },785 ],786 [787 "65539",788 {789 isProxy: true,790 options: {},791 name: "Group 3.Bulb.E27",792 createdAt: 1504794416,793 instanceId: 65539,794 type: 2,795 alive: true,796 lastSeen: 1565008770,797 otaUpdateState: 0,798 deviceInfo: {799 isProxy: true,800 options: {},801 firmwareVersion: "1.2.214",802 manufacturer: "IKEA of Sweden",803 modelNumber: "TRADFRI bulb E27 opal 1000lm",804 power: 1,805 serialNumber: "",806 },807 lightList: [808 {809 onOff: false,810 dimmer: 2,811 color: "f1e0b5",812 transitionTime: 0.5,813 },814 ],815 },816 ],817 [818 "65540",819 {820 isProxy: true,821 options: {},822 name: "Group 3.Bulb.E27",823 createdAt: 1504794519,824 instanceId: 65540,825 type: 2,826 alive: true,827 lastSeen: 1565008764,828 otaUpdateState: 0,829 deviceInfo: {830 isProxy: true,831 options: {},832 firmwareVersion: "1.2.214",833 manufacturer: "IKEA of Sweden",834 modelNumber: "TRADFRI bulb E27 W opal 1000lm",835 power: 1,836 serialNumber: "",837 },838 lightList: [839 {840 onOff: false,841 dimmer: 0.8,842 color: "f1e0b5",843 transitionTime: 0.5,844 },845 ],846 },847 ],848 [849 "65541",850 {851 isProxy: true,852 options: {},853 name: "Group 3.Bulb.E27",854 createdAt: 1504794598,855 instanceId: 65541,856 type: 2,857 alive: true,858 lastSeen: 1565008777,859 otaUpdateState: 0,860 deviceInfo: {861 isProxy: true,862 options: {},863 firmwareVersion: "1.2.214",864 manufacturer: "IKEA of Sweden",865 modelNumber: "TRADFRI bulb E27 opal 1000lm",866 power: 1,867 serialNumber: "",868 },869 lightList: [870 {871 onOff: false,872 dimmer: 2,873 color: "f1e0b5",874 transitionTime: 0.5,875 },876 ],877 },878 ],879 [880 "65542",881 {882 isProxy: true,883 options: {},884 name: "Remote Control Group 2",885 createdAt: 1504795178,886 instanceId: 65542,887 type: 0,888 alive: true,889 lastSeen: 1527390159,890 otaUpdateState: 0,891 deviceInfo: {892 isProxy: true,893 options: {},894 firmwareVersion: "1.2.248",895 manufacturer: "IKEA of Sweden",896 modelNumber: "TRADFRI wireless dimmer",897 power: 3,898 serialNumber: "",899 battery: 47,900 },901 switchList: [902 {903 isProxy: true,904 options: {},905 name: "",906 createdAt: 0,907 instanceId: 0,908 },909 ],910 },911 ],912 [913 "65543",914 {915 isProxy: true,916 options: {},917 name: "Group 2 dimmer",918 createdAt: 1504795441,919 instanceId: 65543,920 type: 0,921 alive: true,922 lastSeen: 1534434305,923 otaUpdateState: 0,924 deviceInfo: {925 isProxy: true,926 options: {},927 firmwareVersion: "1.2.248",928 manufacturer: "IKEA of Sweden",929 modelNumber: "TRADFRI wireless dimmer",930 power: 3,931 serialNumber: "",932 battery: 100,933 },934 switchList: [935 {936 isProxy: true,937 options: {},938 name: "",939 createdAt: 0,940 instanceId: 0,941 },942 ],943 },944 ],945 [946 "65545",947 {948 isProxy: true,949 options: {},950 name: "",951 createdAt: 1511614738,952 instanceId: 65545,953 type: 0,954 alive: true,955 lastSeen: 1542300305,956 otaUpdateState: 0,957 deviceInfo: {958 isProxy: true,959 options: {},960 firmwareVersion: "",961 manufacturer: "",962 modelNumber: "",963 power: 0,964 serialNumber: "",965 },966 switchList: [967 {968 isProxy: true,969 options: {},970 name: "",971 createdAt: 0,972 instanceId: 0,973 },974 ],975 },976 ],977];978module.exports = {979 dummyDevices,980 dummyGroups,...

Full Screen

Full Screen

mvc-db4.js

Source:mvc-db4.js Github

copy

Full Screen

1import {App} from '/~static/project/app.js';2import {utils} from '/~static/lib/client/core/utils.js';3import {io} from "/static/v1/static/lib/client/core/io.js";4import Parser from "/static/v1/static/lib/client/core/rd-parse.js";5import Grammar from "/static/v1/static/lib/client/core/grammar.js";6import {Module} from '/~static/lib/client/core/module.js';7const JSParser = Parser(Grammar);8/*9Built-in10 $updateModel(path, value)11 $readModel(path)12 $setValue(path, val)13 $addCalculated(path, name)14 $addWatched(path, fn)15 $focus(path)16 $display(model)17 $copy(model)18Add-Ons19 $serverProcess(pid, postdata)20 $tableLookup(table, pk, model)21 $tableFilter(query, opts, model)22 $tableInsert(table, model, [clear]) 23 $tableUpdate(table, model, [clear]) 24 $tableUpsert(table, model, [clear]) 25 $tableDelete(table, pk, model) 26 $arrayCopyToObject(array, idx, object)27 $arrayClear(array)28 $arraySet(array, value)29 $objectClear(object)30 $objectSet(object, value)31 $formGet(name)32 $formGet() return parent form, all fields33 $formGet(form) return specified form, all fields34 $formGet(, fld) return parent form, specified field35 $formGet(form, fld) return specified form, specified field 36 $calcSum(model, [condition])37 $condIf(if, [else])38 $urlGetParam(name) also this.model._params Or (_params.name in html)39 $urlGetPath(#)40*/41let addDB4Functions;42export default addDB4Functions = function(MVC) {43 MVC._addProtoMethod('$serverProcess', async function(obj) {44 // $serverProcess(pid, postdata)45 const fnName = '$serverProcess';46 if (obj.args.length != 2) throw new Error(`${fnName} needs exactly 2 arguments: pid and postdata`);47 let [pid, postdata] = obj.args;48 if (!utils.object.isObject(postdata)) throw new Error(`${fnName} post data ${model} is not an object`);49 50 let res = await io.post(postdata, `${App.url}/db4/v1/api/process/${pid}`);51 if (res.status == 200) {52 console.log(res.data)53 }54 else {55 throw new Error(res.message);56 }57 58 return res;59 });60 MVC._addProtoMethod('$tableLookup', async function(obj) {61 // $tableLookup(table, pk, model)62 // model must be a this.model entry.63 const fnName = '$tableLookup';64 if (obj.args.length != 3) throw new Error(`${fnName} needs exactly 3 arguments`);65 let [table, pk, model] = obj.args;66 let isProxy = model.isProxy || false;67console.log('looking for', pk)68 // make sure destination is a model object69 if (!isProxy || !utils.object.isObject(model)) throw new Error(`${fnName} destination model is not a model object`);70 // make sure table has been requested71 if (! (table in Module.table)) throw new Error(`${fnName} Table ${table} not setup`);72 let data = await Module.table[table].getOne(pk, ['*']);73 if (Object.keys(data).length > 0) {74 model = model.proxyFor;75 this.$updateModel(model, data);76 }77 else {78 console.error('No Entry Found', pk);79 }80 return data;81 });82 MVC._addProtoMethod('$tableFilter', async function(obj) {83 // $tableFilter(table, filter, opts, model)84 // model must be a this.model entry.85 // opts: columns, limit, offset86 const fnName = '$tableFilter';87 if (obj.args.length != 4) throw new Error(`${fnName} needs exactly 4 arguments`);88 let [table, filters, opts, model] = obj.args;89 let isProxy = model.isProxy || false;90 // make sure destination is an object91 if (!isProxy || !utils.object.isArray(model)) throw new Error(`${fnName} destination model is not a model array`);92 // filter must be an object93 if (!utils.object.isObject(filters)) throw new Error(`${fnName} filter is not an object`)94 // opts must be an object95 if (!utils.object.isObject(opts)) throw new Error(`${fnName} opts is not an object`)96 //let res = await io.get(opts, `${App.url}/db4/v1/api/query/${query}`);97 let data = await Module.table[table].getMany({filters, columns: opts.columns || ['*'], limit: opts.limit || 1, pffset: opts.offset || 0});98 model = model.proxyFor;99 this.$updateModel(model, res.data);100 return data;101 });102 MVC._addProtoMethod('$tableInsert', async function(obj) {103 // $tableInsert(table, model, [clear]) 104 // model can be an object or a this.model entry105 const fnName = '$tableInsert';106 if (obj.args.length < 2) throw new Error(`${fnName} needs at least 2 arguments`);107 let [table, model, clear] = obj.args;108 let isProxy = model.isProxy || false;109 // make sure source is an object, not necessarily a proxy110 if (!utils.object.isObject(model)) throw new Error(`${fnName} source model is not an object`);111 // has data?112 if (Object.keys(model).length == 0) throw new Error(`${fnName} has no data to insert`);113 // not already exists114 if ('_pk' in model) throw new Error(`${fnName}: existing data cannot be inserted, try $tableUpdate or $tableUpsert`);115 // make sure table has been requested116 if (! (table in Module.table)) throw new Error(`${fnName} Table ${table} not setup`);117 //let res = await io.post(model, `${App.url}/db4/v1/api/${table}`);118 let res = await Module.table[table].insert(model);119 if (res.status == 200) {120 if (isProxy) {121 // only update if a this.model entry122 model = model.proxyFor;123 if (clear) {124 this.$updateModel(model, {});125 }126 else {127 this.$updateModel(model, res.data);128 }129 }130 }131 else {132 throw new Error(res.message);133 }134 return res.data;135 });136 MVC._addProtoMethod('$tableUpdate', async function(obj) {137 // $tableUpdate(table, model, [clear]) 138 const fnName = '$tableUpdate';139 if (obj.args.length < 2) throw new Error(`${fnName} needs at least 2 arguments`);140 let [table, model, clear] = obj.args;141 let isProxy = model.isProxy || false;142 // make sure source is an object143 if (!utils.object.isObject(model)) throw new Error(`${fnName} source model is not an object`);144 // has data145 if (Object.keys(model).length == 0) throw new Error(`${fnName} has no data to insert`);146 // data must be pre-existing147 if (!('_pk' in model)) throw new Error(`${fnName}: existing data cannot be updated, try $tableInsert or $tableUpsert`);148 149 // make sure table has been requested150 if (! (table in Module.table)) throw new Error(`${fnName} Table ${table} not setup`);151 let res = await Module.table[table].update(model._pk, model);152 if (res.status == 200) {153 if (isProxy) {154 // only update if a this.model entry155 model = model.proxyFor;156 if (clear) {157 this.$updateModel(model, {});158 }159 else {160 this.$updateModel(model, res.data);161 }162 }163 }164 else {165 throw new Error(res.message);166 }167 return res.data;168 });169 MVC._addProtoMethod('$tableUpsert', async function(obj) {170 // $tableUpsert(table, model, [clear]) 171 const fnName = '$tableUpsert';172 let res;173 if (obj.args.length < 2) throw new Error(`${fnName} needs at least 2 arguments`);174 let [table, model, clear] = obj.args;175 let isProxy = model.isProxy || false;176 // make sure source is an object177 if (!utils.object.isObject(model)) throw new Error(`${fnName} source model is not an object`);178 // has data179 if (Object.keys(model).length == 0) throw new Error(`${fnName}: no data to insert`);180 // make sure table has been requested181 if (! (table in Module.table)) throw new Error(`${fnName} Table ${table} not setup`); 182 if ('_pk' in model) {183 res = await Module.table[table].update(model);184 }185 else {186 res = await Module.table[table].insert(model);187 } 188 if (res.status == 200) {189 if (isProxy) {190 // only update if a this.model entry191 model = model.proxyFor;192 if (clear) {193 this.$updateModel(model, {});194 }195 else {196 this.$updateModel(model, res.data);197 }198 }199 }200 else {201 throw new Error(res.message);202 }203 return res.data;204 });205 MVC._addProtoMethod('$tableDelete', async function(obj) {206 // $tableDelete(table, pk, model) 207 const fnName = '$tableDelete';208 if (obj.args.length < 3) throw new Error(`${fnName} needs at least 3 arguments`);209 let [table, pk, model] = obj.args;210 let isProxy = model.isProxy || false;211 // make sure table has been requested212 if (! (table in Module.table)) throw new Error(`${fnName} Table ${table} not setup`); 213 let res = await Module.table[table].delete(pk);214 if (res.status == 200) {215 if (isProxy) {216 // only update if a this.model entry217 model = model.proxyFor;218 this.$updateModel(model, {});219 }220 else {221 throw new Error(res.message);222 }223 }224 return {};225 });226 MVC._addProtoMethod('$arrayCopyToObject', function(obj) {227 // $arrayCopyToObject(array, idx, object)228 // any array, model object229 const fnName = '$arrayCopyToObject';230 if (obj.args.length != 3) throw new Error(`${fnName} needs exactly 3 arguments`);231 let [array, idx, object] = obj.args;232 let objectProxy = object.isProxy || false;233 if (!utils.object.isArray(array)) throw new Error(`${fnName}: Invalid Array`);234 if (!objectProxy || !utils.object.isObject(object)) throw new Error(`${fnName}: Invalid Object`);235 let entry = array[idx];236 object = object.proxyFor;237 this.$updateModel(object, entry);238 return entry;239 });240 MVC._addProtoMethod('$arrayClear', function(obj) {241 // $arrayClear(array)242 const fnName = 'arrayClear';243 if (obj.args.length != 1) throw new Error(`${fnName} needs exactly 1 argument`);244 let array = obj.args[0];245 let isProxy = array.isProxy || false;246 if (!isProxy || !utils.object.isArray(array)) throw new Error(`${fnName}: Invalid Array`);247 array = array.proxyFor;248 this.$updateModel(array, []);249 return [];250 });251 MVC._addProtoMethod('$arraySet', function(obj) {252 // $arraySet(array, value)253 const fnName = 'arraySet';254 if (obj.args.length != 2) throw new Error(`${fnName} needs exactly 2 arguments`);255 let [array, value] = obj.args;256 let arrayProxy = array.isProxy || false;257 if (!arrayProxy || !utils.object.isArray(array)) throw new Error(`${fnName}: Destination is not a model Array`);258 if (!utils.object.isArray(value)) throw new Error(`${fnName}: Source is not an Array`);259 array = array.proxyFor;260 this.$updateModel(array, valueData);261 return value;262 });263 MVC._addProtoMethod('$objectClear', function(obj) {264 // $objectClear(object)265 const fnName = 'objectClear';266 if (obj.args.length != 1) throw new Error(`${fnName} needs exactly 1 argument`);267 let object = obj.args[0];268 let isProxy = object.isProxy || false;269 if (!isProxy || !utils.object.isObject(object)) throw new Error(`${fnName}: Invalid Object`);270 object = object.proxyFor;271 this.$updateModel(object, {});272 return {};273 });274 MVC._addProtoMethod('$objectSet', function(obj) {275 // $objectSet(object, value)276 const fnName = 'objectSet';277 if (obj.args.length != 2) throw new Error(`${fnName} needs exactly 2 arguments`);278 let [object, value] = obj.args;279 let objectProxy = object.isProxy || false;280 if (!objectProxy || !utils.object.isObject(object)) throw new Error(`${fnName}: Destination is not a model Object`);281 if (!utils.object.isObject(value)) throw new Error(`${fnName}: Source is not an Object`);282 object = object.proxyFor;283 this.$updateModel(object, valueData);284 return value;285 });286 MVC._addProtoMethod('$formGet', function(obj) {287 // $formGet(name)288 // 289 // $formGet() return parent form, all fields290 // $formGet(form) return specified form, all fields291 // $formGet(, fld) return parent form, specified field292 // $formGet(form, fld) return specified form, specified field293 294 const fnName = '$formGet';295 let result = {};296 const getSpecifiedForm = function(f) {297 return (f.substr(0,1) == '#' || f.substr(0,1) == '.') ? document.querySelector(f) : document.querySelector(`form[name=${f}]`);298 }299 const getParentForm = function() {300 return obj.target.closest('form');301 }302 let [form, fldName] = obj.args;303 let formEl = (form) ? getSpecifiedForm(form) : getParentForm();304 if (!formEl) throw new Error(`${fnName}: Invalid Form: ${form}`);305 for (let el of formEl) {306 if (fldName) {307 if (el.name == fldName) {308 return el.value;309 }310 }311 else {312 if (el.name) result[el.name] = el.value;313 }314 }315 return result;316 });317 318 MVC._addProtoMethod('$calcSum', async function(obj) {319 // $calcSum(model, field, [cond])320 const fnName = '$calcSum';321 let sum = 0;322 let ast;323 if (obj.args.length < 2) throw new Error(`${fnName} needs at least 2 arguments`);324 let [path, field, cond] = obj.args;325 if (cond) ast = JSParser(cond);326 let data = this.$readModel(path);327 let arrayProxy = data.isProxy || false;328 if (!arrayProxy || !utils.object.isArray(data)) throw new Error(`${fnName}: Source is not a model Array`);329 for (let idx=0, res; idx<data.length; idx++) {330 this.$updateModel('$index', idx);331 332 res = (cond) ? await this._jsParse(null, ast) : true;333 if (res) sum += data[idx][field] || 0;334 }335 return sum;336 });337 MVC._addProtoMethod('$urlGetParam', function(obj) {338 // $urlGetParam(name)339 const fnName = '$urlGetParam';340 if (obj.args.length != 1) throw new Error(`${fnName} needs exactly 1 argument`);341 let [name] = obj.args;342 for (let q of location.search.substr(1).split('&')) {343 let nvp = q.split('=');344 obj[nvp[0]] = nvp[1];345 }346 return obj[name] || ''; 347 });348 MVC._addProtoMethod('$urlGetPath', function(obj) {349 // $urlGetPath(#)350 // path split, 1 based.351 // neg# is from end.352 // [1,2,3] = [-3,-2,-1]353 const fnName = '$urlGetPath';354 let path;355 if (obj.args.length != 1) throw new Error(`${fnName} needs exactly 1 argument`);356 let [fldNo] = obj.args;357 358 if (isNaN(fldNo)) throw new Error(`${fnName} Invalid Position# ${fldNo}`);359 if (fldNo < 0) {360 path = path.reverse();361 fldNo = Math.abs(fldNo);362 }363 fldNo--;364 if (path.length <= fldNo) return '';365 return path[fldNo];366 });...

Full Screen

Full Screen

allproxies.js

Source:allproxies.js Github

copy

Full Screen

1var unproxy = new WeakMap();2function isProxy(p) {3 if (typeof p !== 'object')4 return false;5 else6 return unproxy.has(p);7}8var secret = {};9// String->Int->Quantity->Quantity10function makeQuantity(u, i, n) {11 var h = null;12 if (isProxy(n)) {13 //*** DEBUG14 console.log("makeQuantity: fetching n.handler...");15 16 h = unproxy.get(n).handler;17 }18 if (i === 0)19 return n;20 else if (h && h.unit === u) {21 //*** DEBUG22 console.log("makeQuantity returning: unit = "+u+", index = "+(h.index+i)+", value = "+h.val);23 24 var ix = h.index + i;25 return makeQuantity(u, ix, h.val);26 }else if (h && h.unit > u) {27 //*** DEBUG28 console.log("makeQuantity returning: unit = "+h.unit+", index = "+(h.index)+", value = Quantity {"+u+", "+i+", "+h.val+"}");29 return makeQuantity(h.unit, h.index, makeQuantity(u, i, h.val));30 }else {31 var handle = {32 unit: u,33 index: i,34 val: n,35 // ops36 unary: function(o) {37 return unitUnaryOps[o].call(null, this.unit, this.index, this.val);38 },39 left: function(o, r) {40 return unitLeftOps[o].call(null, this.unit, this.index, this.val, r);41 },42 right: function(o, l) {43 return unitRightOps[o].call(null, this.unit, this.index, this.val, l);44 },45 test: function() {46 return getValue(this.val);47 }48 };49 var p = new Proxy(secret, handle);50 unproxy.set(p, {51 handler: handle52 });53 //*** DEBUG54 var bsunit = unproxy.get(p).handler.unit;55 var bsindex = unproxy.get(p).handler.index;56 var bsvalue = unproxy.get(p).handler.val;57 console.log("just made Quantity: unit = "+bsunit+", index = "+bsindex+", value = "+bsvalue);58 var tp = typeof p;59 console.log("type of p = "+tp);60 return p;61 }62}63var unitUnaryOps = {64 "-": function(u, i, n) {65 makeQuantity(u, i, proxyMinus(n));66 }67}68var unitLeftOps = {69 "+": function(u, i, n, r) {70 return makeQuantity(u, i, proxyAdd(n, dropUnit(u, i, r)));71 },72 "-": function(u, i, n, r) {73 return makeQuantity(u, i, proxySub(n, dropUnit(u, i, r)));74 },75 "*": function(u, i, n, r) {76 return makeQuantity.call(null, u, i, proxyMult(n, r));77 },78 "/": function(u, i, n, r) {79 return makeQuantity(u, i, proxyDiv(n, r));80 },81 "=": function(u, i, n, r) {82 n = (dropUnit(u, i, r));83 return n;84 }85 // Add more binary ops86}87var unitRightOps = {88 // left arg is never a proxy!89 "+": function(u, i, n, l) {90 alert("Can't add Num to Unit of measure\nWe're Screwed!");91 },92 "-": function(u, i, n, l) {93 alert("Can't subtract Num to Unit of measure\nWe're Screwed!");94 },95 "*": function(u, i, n, l) {96 return makeQuantity.call(null, u, i, proxyMult(l, n));97 },98 "/": function(u, i, n, l) {99 return makeQuantity(u, (-i), proxyDiv(l, n));100 },101 "=": function(u, i, n, l) {102 alert("= UNIT MISMATCH can't assign");103 }104 // Add more binary ops105}106function dropUnit(u, i, n) {107 var h = null;108 if (isProxy(n))109 h = unproxy.get(n).handler;110 if (h !== null && h.unit === u && h.index === i) {111 return h.val;112 }else {113 alert("Could not dropUnit BEEZY");114 }115}116var unitRecord = {117 // String->Quantity118 makeUnit: function (u) {119 return makeQuantity(u, 1, 1);120 }121}122function getValue(n) {123 var h = null;124 if (isProxy(n)) {125 console.log("getValue: setting h = handler");126 h = unproxy.get(n).handler;127 }128 if (h !== null) {129 console.log("getValue recursing...");130 return getValue(h.val);131 }else {132 console.log("getValue returning" + n);133 return n;134 }135}136function mtoKmThunk (q) {137 return { c: f, arg: q, computed: false };138};139var f = function() {140 // COME BACK TO THIS THUNK LATER!141 if (!this.computed) {142 this.computed = true;143 }144 var km = unitRecord['makeUnit'].call(null, "kilometer");145 var res = proxyMult((getValue(this.arg) / 1000), km);146 return res;147};148function delay(thunk) {149 var r;150 var z = function () {151 if(!thunk.computed) {152 r = thunk.c();153 }154 console.log("delay: z: returning r = "+r+"\nrvalue = "+getValue(r));155 return r;156 }157 var handle = {158 unary: function(o) {159 return unaryOps(z());160 },161 left: function (o, r) {162 return binOps[o].call(null, z(), r);163 },164 right: function (o, l) {165 return binOps[o].call(null, z(), l);166 },167 test: function() {168 return getValue(z());169 }170 };171 var p = new Proxy (secret, handle);172 unproxy.set(p, {173 handler: handle174 });175 return p;176}177var unaryOps = {178 "-": function(x) {179 return -x;180 }181}182var binOps = {183 "+": function(l, r) {184 return proxyAdd(l, r);185 },186 "-": function(l, r) {187 return proxySub(l, r);188 },189 "/": function (l, r) {190 return proxyDiv(l, r);191 },192 "*": function (l, r) {193 return proxyMult(l, r);194 },195 //Add other binary ops196}197function proxyEq (l, r) {198 var lhs, rhs;199 if (isProxy(l) && isProxy(r)) {200 lhs = unproxy.get(l).handler.test();201 rhs = unproxy.get(r).handler.test();202 return lhs === rhs;203 }else if (isProxy(l)) {204 lhs = unproxy.get(l).handler.test();205 return lhs === r;206 }else if (isProxy(r)) {207 rhs = unproxy.get(r).handler.test();208 return l === rhs;209 }else {210 return l === r;211 }212}213function proxyGt (l, r) {214 var lhs, rhs;215 if (isProxy(l) && isProxy(r)) {216 lhs = unproxy.get(l).handler.test();217 rhs = unproxy.get(r).handler.test();218 return lhs > rhs;219 }else if (isProxy(l)) {220 lhs = unproxy.get(l).handler.test();221 return lhs > r;222 }else if (isProxy(r)) {223 rhs = unproxy.get(r).handler.test();224 return l > rhs;225 }else {226 return l > r;227 }228}229function proxyMult (l, r) {230 if (isProxy(l)) {231 return unproxy.get(l).handler.left("*", r);232 }else if (isProxy(r)) {233 return unproxy.get(r).handler.right("*", l);234 }else {235 return l * r;236 }237}238function proxyAdd (l, r) {239 if (isProxy(l)) {240 return unproxy.get(l).handler.left("+", r);241 }else if (isProxy(r)) {242 return unproxy.get(r).handler.right("+", l);243 }else {244 return l + r;245 }246}247function proxyDiv (l, r) {248 if (isProxy(l)) {249 return unproxy.get(l).handler.left("/", r);250 }else if (isProxy(r)) {251 return unproxy.get(r).handler.right("/", l);252 }else {253 return l / r;254 }255}256function proxySub (l, r) {257 if (isProxy(l)) {258 return unproxy.get(l).handler.left("-", r);259 }else if (isProxy(r)) {260 return unproxy.get(r).handler.right("-", l);261 }else {262 return l - r;263 }264}265function proxyMinus(r) {266 if (isProxy(r)) {267 return unproxy.get(r).handler.unary("-");268 }else {269 return -r;270 }271}272(function() {273 macro + {274 rule infix { $lhs:expr | $rhs:expr } => {275 proxyAdd($lhs, $rhs)276 }277 }278 macro - {279 rule infix { $lhs:expr | $rhs:expr } => {280 proxySub($lhs, $rhs)...

Full Screen

Full Screen

index.test.js

Source:index.test.js Github

copy

Full Screen

...55 expect(apply).toHaveBeenCalled();56};57var testWithProxiedValues = function(ProxyConstructor, isProxy) {58 var obj = { proxy: new ProxyConstructor({}, {}) };59 expect(isProxy(obj.proxy)).toBeTruthy();60 expect(isProxy(new ProxyConstructor({ abc: 1 }, {}))).toBeTruthy();61 expect(isProxy(new ProxyConstructor({}, {}))).toBeTruthy();62 expect(isProxy(ProxyConstructor.revocable({}, {}).proxy)).toBeTruthy();63 expect(isProxy(new ProxyConstructor([1, 2, 3], {}))).toBeTruthy();64 expect(isProxy(new ProxyConstructor(() => {}, {}))).toBeTruthy();65 expect(isProxy(new ProxyConstructor(function() {}, {}))).toBeTruthy();66 expect(67 isProxy(68 new ProxyConstructor(69 { g: '1' },70 {71 get(target, prop, receiver) {72 return Reflect.get(target, prop, receiver);73 }74 }75 )76 )77 ).toBeTruthy();78};79var testWithNotProxiedValues = function(isProxy) {80 expect(isProxy({ qwerty: 123 })).toBeFalsy();81 expect(isProxy(321)).toBeFalsy();82 expect(isProxy('abc')).toBeFalsy();83 expect(isProxy(false)).toBeFalsy();84 expect(isProxy(true)).toBeFalsy();85 expect(isProxy([1, 2, 3])).toBeFalsy();86 expect(isProxy(new GlobalProxy({}, {}))).toBeFalsy();87 expect(isProxy(GlobalProxy.revocable({}, {}))).toBeFalsy();88 expect(isProxy(undefined)).toBeFalsy();89 expect(isProxy(null)).toBeFalsy();90 expect(isProxy(123n)).toBeFalsy();91 expect(isProxy(() => {})).toBeFalsy();92 expect(isProxy(function() {})).toBeFalsy();93 expect(isProxy(new Boolean(false))).toBeFalsy();94 expect(isProxy(Symbol('test'))).toBeFalsy();95 expect(isProxy(/test/)).toBeFalsy();96};97var testGarbageCollectedProxy = function(ProxyConstructor, isProxy) {98 var obj = {99 proxy: new ProxyConstructor({}, {}),100 proxyRevocable: ProxyConstructor.revocable({}, {}).proxy101 };102 expect(isProxy(obj.proxy)).toBeTruthy();103 delete obj.proxy;104 expect(isProxy(obj.proxy)).toBeFalsy();105 expect(isProxy(obj.proxyRevocable)).toBeTruthy();106 delete obj.proxyRevocable;107 expect(isProxy(obj.proxyRevocable)).toBeFalsy();108};109describe('Pure isProxy works fine', () => {110 var Proxy;111 var isProxy;112 beforeAll(() => {113 var pure = require('./pure');114 Proxy = pure.Proxy;115 isProxy = pure.isProxy;116 });117 test('should execute proxy traps', () => {118 testTraps(traps => new Proxy(function() {}, traps));119 testTraps(traps => Proxy.revocable(function() {}, traps).proxy);120 });121 test('should be true when the value is a proxy object', () => {...

Full Screen

Full Screen

knownAddresses.js

Source:knownAddresses.js Github

copy

Full Screen

1const Web3 = require("web3");2const knownTokenAddresses = {3 "cBAT": "0x6c8c6b02e7b2be14d4fa6022dfd6d75921d90e4e",4 "cCOMP": "0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",5 "cDAI": "0x5d3a536e4d6dbd6114cc1ead35777bab948e3643",6 "cETH": "0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",7 "cUSDC": "0x39aa39c021dfbae8fac545936693ac917d5e7563",8 "cUSDT": "0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9",9 "cREP": "0x158079ee67fce2f58472a96584a73c7ab9ac95c1",10 "cSAI": "0xf5dce57282a584d2746faf1593d3121fcac444dc",11 "cUNI": "0x35a18000230da775cac24873d00ff85bccded550",12 "cUSDC": "0x39aa39c021dfbae8fac545936693ac917d5e7563",13 "cWBTC": "0xc11b1268c1a384e55c48c2391d8d480264a3a7f4",14 "cZRX": "0xb3319f5d18bc0d84dd1b4825dcde5d5f7266d407",15 "DAI": "0x6b175474e89094c44da98b954eedeac495271d0f",16 "BAT": "0x0D8775F648430679A709E98d2b0Cb6250d2887EF",17 "USDC": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",18 "USDT": "0xdAC17F958D2ee523a2206206994597C13D831ec7",19 "WETH": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",20 "WBTC": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",21 "aDAI": "0x028171bCA77440897B824Ca71D1c56caC55b68A3"22 }23const knownProxyContractPair = {24 "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B": "0xbe7616b06f71e363a310aa8ce8ad99654401ead7", //Compound comtroller25 "0x028171bCA77440897B824Ca71D1c56caC55b68A3": "0xb7bf8e4908ad1caf1a638b30ef80afc581fdc968", //aDAI26 "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": "0xb7277a6e95992041568d9391d09d0122023778a2", //USDC27 "0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9": "0xc6845a5c768bf8d7681249f8927877efda425baf", //InitializableImmutableAdminUpgradeabilityProxy28 "0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3": "0x5766067108e534419ce13f05899bc3e3f4344948", //InitializableAdminUpgradeabilityProxy29 "0x398eC7346DcD622eDc5ae82352F02bE94C62d119": "0x017788dded30fdd859d295b90d4e41a19393f423"30}31const knownContracts =32[33 {34 "ContractName": "UniswapAnchoredView",35 "Address": "0x922018674c12a7f0d394ebeef9b58f186cde13c1",36 "IsProxy": false37 },38 {39 "ContractName": "Comptroller",40 "Address": "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B",41 "IsProxy": true42 },43 {44 "ContractName": "UniswapV2Router02",45 "Address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",46 "IsProxy": false47 },48 {49 "ContractName": "UniswapV2Factory",50 "Address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",51 "IsProxy": false52 },53 {54 "ContractName": "InitializableImmutableAdminUpgradeabilityProxy",55 "Address": "0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9",56 "IsProxy": true57 },58 {59 "ContractName": "InitializableAdminUpgradeabilityProxyV1",60 "Address": "0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3",61 "IsProxy": true62 },63 {64 "ContractName": "InitializableAdminUpgradeabilityProxyV1.1",65 "Address": "0x398eC7346DcD622eDc5ae82352F02bE94C62d119",66 "IsProxy": true67 },68 {69 "ContractName": "OpenOraclePriceData",70 "Address": "0xc629c26dced4277419cde234012f8160a0278a79",71 "IsProxy": false72 }73]74async function findContractAddress(contractName){75 for(var i = 0; i < knownContracts.length; i++){76 if(knownContracts[i].ContractName == contractName){77 return Web3.utils.toChecksumAddress(knownContracts[i].Address);78 }79 }80}81module.exports ={82 knownTokenAddresses, knownProxyContractPair, knownContracts, findContractAddress...

Full Screen

Full Screen

connection.js

Source:connection.js Github

copy

Full Screen

1const getMap = (data) =>2 `https://maps.googleapis.com/maps/api/staticmap?center=${data.lat},${data.lon}&markers=color:red%7Clabel:%7C${data.lat},${data.lon}&size=500x200&zoom=10&key=AIzaSyB-YN-X8PGBSPd7NOaQu4csVhgJUnF3ZGk`;3const compareTimeZone = (locationTimeZone, workerTimeZone) => {4 if (locationTimeZone !== workerTimeZone) {5 return "Location data doesn't match system data";6 }7 return null;8};9const checkProxy = (proxy) => {10 if (proxy) {11 return 'VPN/proxy has been detected';12 }13 return null;14};15// Returns object with location data16const getLocation = (data, workerData) => {17 const timeZoneIssue = compareTimeZone(data.timezone, workerData.timeZone);18 const isProxy = checkProxy(data.proxy);19 return [20 {21 key: 'Country',22 value: data.country,23 issues: [timeZoneIssue, isProxy],24 },25 {26 key: 'Region',27 value: data.regionName,28 issues: [timeZoneIssue, isProxy],29 },30 {31 key: 'City',32 value: data.city,33 issues: [timeZoneIssue, isProxy],34 },35 {36 key: 'Time zone',37 value: data.timezone,38 issues: [timeZoneIssue, isProxy],39 },40 {41 key: 'Zip code',42 value: data.zip,43 issues: [timeZoneIssue, isProxy],44 },45 {46 key: 'Latitude',47 value: data.lat,48 issues: [timeZoneIssue, isProxy],49 },50 {51 key: 'Longitude',52 value: data.lon,53 issues: [timeZoneIssue, isProxy],54 },55 ];56};57// Returns object with location data58const getConnection = (data) => {59 const isProxy = checkProxy(data.proxy);60 return [61 {62 key: 'IP address',63 value: data.query,64 issues: [isProxy],65 },66 {67 key: 'ISP',68 value: data.isp,69 issues: [isProxy],70 },71 {72 key: 'Org',73 value: data.org,74 issues: [isProxy],75 },76 {77 key: 'ASN',78 value: data.as,79 issues: [isProxy],80 },81 ];82};...

Full Screen

Full Screen

Object-proxy.js

Source:Object-proxy.js Github

copy

Full Screen

1// Debugger.Object.prototype.isProxy recognizes (scripted) proxies.2// Debugger.Object.prototype.proxyTarget exposes the [[Proxytarget]] of a proxy.3// Debugger.Object.prototype.proxyHandler exposes the [[ProxyHandler]] of a proxy.4var g = newGlobal();5var dbg = new Debugger;6var gDO = dbg.addDebuggee(g);7g.eval('var target = [1,2,3];');8g.eval('var handler = {has: ()=>false};');9g.eval('var proxy = new Proxy(target, handler);');10g.eval('var proxyProxy = new Proxy(proxy, proxy);');11g.eval('var revoker = Proxy.revocable(target, handler);');12g.eval('var revocable = revoker.proxy;');13var target = gDO.getOwnPropertyDescriptor('target').value;14var handler = gDO.getOwnPropertyDescriptor('handler').value;15var proxy = gDO.getOwnPropertyDescriptor('proxy').value;16var proxyProxy = gDO.getOwnPropertyDescriptor('proxyProxy').value;17var revocable = gDO.getOwnPropertyDescriptor('revocable').value;18assertEq(target.isProxy, false);19assertEq(target.proxyTarget, undefined);20assertEq(target.proxyHandler, undefined);21assertEq(handler.isProxy, false);22assertEq(handler.proxyTarget, undefined);23assertEq(handler.proxyHandler, undefined);24assertEq(proxy.isProxy, true);25assertEq(proxy.proxyTarget, target);26assertEq(proxy.proxyHandler, handler);27assertEq(proxyProxy.isProxy, true);28assertEq(proxyProxy.proxyTarget, proxy);29assertEq(proxyProxy.proxyHandler, proxy);30assertEq(revocable.isProxy, true);31assertEq(revocable.proxyTarget, target);32assertEq(revocable.proxyHandler, handler);33g.eval('revoker.revoke();');34assertEq(revocable.isProxy, true);35assertEq(revocable.proxyTarget, null);...

Full Screen

Full Screen

test_isProxy.js

Source:test_isProxy.js Github

copy

Full Screen

...7 37;8 }9 };10 var p = new Proxy({}, handler);11 do_check_true(Cu.isProxy(p));12 do_check_false(Cu.isProxy({}));13 do_check_false(Cu.isProxy(42));14 sb = new Cu.Sandbox(this,15 { wantExportHelpers: true });16 do_check_false(Cu.isProxy(sb));17 sb.do_check_true = do_check_true;18 sb.do_check_false = do_check_false;19 sb.p = p;20 Cu.evalInSandbox('do_check_true(isProxy(p));' +21 'do_check_false(isProxy({}));' +22 'do_check_false(isProxy(42));',23 sb);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isProxy } = require('playwright/lib/utils/utils');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 console.log(isProxy(page));8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isProxy } = require('playwright/lib/utils/utils');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const [response] = await Promise.all([8 page.waitForNavigation(),9 page.click('text=Docs')10 ]);11 console.log(isProxy(response));12 await browser.close();13})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isProxy } = require('playwright/lib/utils/utils');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const input = await page.$('input[name="q"]');7 console.log(isProxy(input));8 await browser.close();9})();10getUnderlyingObject()11getUnderlyingValue()12const { getUnderlyingObject } = require('playwright/lib/utils/utils');13const { chromium } = require('playwright');14(async () => {15 const browser = await chromium.launch();16 const page = await browser.newPage();17 const input = await page.$('input[name="q"]');18 const actualInput = getUnderlyingObject(input);19 await actualInput.type('Hello World');20 await browser.close();21})();22const { getUnderlyingObject, getUnderlyingValue } = require('playwright/lib/utils/utils');23const { chromium } = require('playwright');24(async () => {25 const browser = await chromium.launch();26 const page = await browser.newPage();27 const input = await page.$('input[name="q"]');28 const actualInput = getUnderlyingObject(input);29 await actualInput.type('Hello World');30 const actualInputValue = getUnderlyingValue(input);31 console.log(actualInputValue);32 await browser.close();33})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isProxy } = require('@playwright/test/lib/utils/utils');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const title = await page.title();7 console.log(isProxy(title));8 await browser.close();9})();10const { isProxy } = require('@playwright/test/lib/utils/utils');11const { chromium } = require('playwright');12(async () => {13 const browser = await chromium.launch();14 const page = await browser.newPage();15 const title = await page.title();16 console.log(title);17 console.log(isProxy(title));18 await browser.close();19})();20const { isProxy } = require('@playwright/test/lib/utils/utils');21const { chromium } = require('playwright');22(async () => {23 const browser = await chromium.launch();24 const page = await browser.newPage();25 const title = await page.title();26 console.log(title);27 console.log(isProxy(title));28 await browser.close();29})();30Recommended Posts: Playwright | isString() method31Playwright | isRegExp() method32Playwright | isNumber() method33Playwright | isBoolean() method34Playwright | isObject() method35Playwright | isDate() method36Playwright | isUndefined() method37Playwright | isNull() method

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isProxy } = require('playwright/lib/utils/utils.js');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const title = await page.title();8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isProxy } = require('playwright/lib/client/selectorEngine');2const { firefox } = require('playwright');3(async () => {4 const browser = await firefox.launch();5 const page = await browser.newPage();6 const elementHandle = await page.$('text=Get started');7 console.log(isProxy(elementHandle));8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isProxy } = require('playwright/lib/utils/utils');2const { isProxy } = require('playwright/lib/utils/utils');3 throw err;4 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)5 at Function.Module._load (internal/modules/cjs/loader.js:725:27)6 at Module.require (internal/modules/cjs/loader.js:952:19)7 at require (internal/modules/cjs/helpers.js:88:18)8 at Object.<anonymous> (/Users/david/Projects/playwright-test/test.js:1:23)9 at Module._compile (internal/modules/cjs/loader.js:1063:30)10 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)11 at Module.load (internal/modules/cjs/loader.js:928:32)12 at Function.Module._load (internal/modules/cjs/loader.js:769:14)13 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {14}15const { isProxy } = require('playwright/lib/utils/utils');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { isProxy } from "playwright/lib/server/supplements/recorder/recorderSupplement";2import { Page } from "playwright";3const page: Page = await browser.newPage();4console.log(isProxy(page));5await page.close();6import { isProxy } from "puppeteer/lib/cjs/puppeteer/common/Connection";7import puppeteer from "puppeteer";8const browser = await puppeteer.launch();9const page = await browser.newPage();10console.log(isProxy(page));11await page.close();12await browser.close();13import { isProxy } from "webdriverio/build/utils";14import { remote } from "webdriverio";15const browser = await remote({16 capabilities: {17 },18});19console.log(isProxy(browser));20await browser.deleteSession();21import { isProxy } from "@cypress/browserify-preprocessor/node_modules/@cypress/webpack-preprocessor/node_modules/webpack/lib/NormalModule";22import cypress from "cypress";23const browser = await cypress.launch();24const page = await browser.newPage();25console.log(isProxy(page));26await page.close();27await browser.close();28import { isProxy } from "testcafe/lib/configuration/configuration-base";29import { Selector } from "testcafe";30const selector = Selector("button");31console.log(isProxy(selector));32import { isProxy } from "playwright/lib/server/supplements/recorder/recorderSupplement";33import { Page } from "playwright";34const page: Page = await browser.newPage();35console.log(isProxy(page));36await page.close();37import { isProxy } from "puppeteer/lib/cjs/puppeteer/common/Connection";38import puppeteer from "puppeteer";39const browser = await puppeteer.launch();40const page = await browser.newPage();41await page.goto("http

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful