Best JavaScript code snippet using ladle
bootstrap.js
Source:bootstrap.js
1function Word(vocab, name, source, func) {2 this.vocab = vocab;3 this.name = name;4 this.source = source;5 this.func = func;6}7Word.prototype.execute = function(next) {8 this.func(next);9}10Word.prototype.toString = function() {11 var html = [];12 html.push("<a href='/responder/browser/browse?vocab=")13 html.push(this.vocab);14 html.push("&word=")15 html.push(this.name);16 html.push("'>")17 html.push(this.name);18 html.push("</a>");19 return html.join("");20}21function Hashtable() {22 this.table = { }23}24Hashtable.prototype.fromAlist = function(alist) {25 var obj = { }26 for(var i=0;i<alist.length;++i) { 27 var item = alist[i];28 obj[item[0]] = item[1];29 }30 this.table = obj;31 return this;32}33Hashtable.prototype.toAlist = function() {34 var table = this.table;35 var alist = [ ];36 for(k in table) {37 var v = table[k];38 alist.push([k,v]);39 }40 return alist;41}42Hashtable.prototype.get = function(key) {43 var table = this.table;44 if(table.hasOwnProperty(key)) {45 return table[key];46 }47 return false;48}49Hashtable.prototype.set = function(key, value) {50 this.table[key] = value;51}52Hashtable.prototype.toString = function() {53 var table = this.table;54 var result = [];55 result.push("H{")56 for(k in table) {57 var v = table[k];58 result.push(" { ");59 result.push(k);60 result.push(" ");61 result.push(v);62 result.push(" }");63 }64 result.push("}");65 return result.join(""); 66}67function Continuation() {68 this.data_stack = [ ];69 this.retain_stack = [ ];70 this.name_stack = [ ];71 this.next = false;72 this.nesting = 0;73}74Continuation.prototype.clone = function() {75 var c = new Continuation();76 c.data_stack = this.data_stack.slice(0);77 c.retain_stack = this.retain_stack.slice(0);78 c.name_stack = this.name_stack.slice(0);79 c.nesting = this.nesting;80 c.next = this.next;81 return c;82}83function Factor() {84 this.vocabs = { scratchpad: { }, io: { } };85 this.in_vocab = "scratchpad";86 this.using_vocabs = [ "scratchpad", "kernel","math","sequences","parser","alien","browser-dom", "words", "io", "hashtables" ];87 this.cont = new Continuation();88}89var factor = new Factor();90Factor.prototype.call_next = function(next) {91 if(next) {92 if(this.cont.nesting++ > 150) {93 this.cont.nesting = 0;94 setTimeout(next, 0);95 }96 else {97 next();98 }99 }100}101Factor.prototype.push_data = function(v, next) {102 factor.cont.data_stack.push(v);103 factor.call_next(next);104}105Factor.prototype.use = function(v, next) {106 factor.cont.data_stack.push(v);107 factor.get_word("kernel", "use+").execute(next);108}109Factor.prototype.using = function(v, next) {110 factor.cont.data_stack.push(v);111 factor.get_word("kernel", "using").execute(next);112}113var fjsc_repl = false;114Factor.prototype.set_in = function(v, next) {115 factor.cont.data_stack.push(v);116 factor.get_word("kernel", "set-in").execute(next);117 if (fjsc_repl) {118 fjsc_repl.ps = '( ' + v + ' )';119 }120}121Factor.prototype.get_word = function(vocab,name) {122 return factor.vocabs[vocab][name];123}124Factor.prototype.find_word = function(name) {125 for(var v = 0; v<factor.using_vocabs.length; ++v) {126 var w = factor.vocabs[factor.using_vocabs[v]][name];127 if(w)128 return w;129 }130 return false;131}132Factor.prototype.add_word = function(vocab,name, source, func) {133 var v = factor.vocabs[vocab];134 if(!v) {135 v = { };136 factor.vocabs[vocab] = v;137 }138 v[name] = new Word(vocab,name,source,func);139}140Factor.prototype.remove_word = function(vocab,name) {141 var v = factor.vocabs[vocab];142 if(!v) {143 v = { };144 factor.vocabs[vocab] = v;145 }146 delete v[name];147}148 149Factor.prototype.define_word = function(name, source, func, next) {150 factor.vocabs[factor.in_vocab][name] = new Word(factor.in_vocab, name, source, function(next) {151 var old = factor.cont.next;152 factor.cont.next = function() {153 factor.cont.next = old;154 factor.call_next(next);155 }156 func();157 });158 factor.call_next(next);159}160Factor.prototype.make_quotation = function(source, func) {161 return new Word("quotations", "quotation", source, function(next) {162 var old = factor.cont.next;163 factor.cont.next = function() {164 factor.cont.next = old;165 factor.call_next(next);166 }167 func();168 });169}170Factor.prototype.server_eval = function(text, handler, next) {171 var self = this;172 $.post("compile", { code: text }, function(result) {173 factor.run_eval = function(func) {174 factor.cont.next = function() { handler(text,result); } 175 try {176 func(factor);177 } catch(ex) {178 alert("Error Parsing Javascript: " + ex); 179 handler(text, result);180 }181 if(next) 182 factor.call_next(next);183 }184 try {185 eval("factor.run_eval" + result);186 } catch(e) {187 factor.run_eval(function() { alert("Error Parsing Javascript: " + e); });188 }189 });190}191/* kernel-internals vocabulary */192factor.add_word("kernel-internals", ">n", "primitive", function(next) {193 var data_stack = factor.cont.data_stack;194 var name_stack = factor.cont.name_stack;195 name_stack.push(data_stack.pop());196 factor.call_next(next);197});198factor.add_word("kernel-internals", "n>", "primitive", function(next) {199 var data_stack = factor.cont.data_stack;200 var name_stack = factor.cont.name_stack;201 data_stack.push(name_stack.pop());202 factor.call_next(next);203});204/* Kernel Vocabulary */205factor.add_word("kernel","dup", "primitive", function(next) {206 var stack = factor.cont.data_stack;207 stack[stack.length] = stack[stack.length-1];208 factor.call_next(next);209});210factor.add_word("kernel", "drop", "primitive", function(next) {211 factor.cont.data_stack.pop();212 factor.call_next(next);213});214factor.add_word("kernel", "nip", "primitive", function(next) {215 var stack = factor.cont.data_stack;216 stack[stack.length-2] = stack[stack.length-1];217 stack.pop();218 factor.call_next(next);219});220factor.add_word("kernel", "over", "primitive", function(next) {221 var stack = factor.cont.data_stack;222 stack[stack.length] = stack[stack.length-2];223 factor.call_next(next);224});225factor.add_word("kernel", "pick", "primitive", function(next) {226 var stack = factor.cont.data_stack;227 stack[stack.length] = stack[stack.length-3];228 factor.call_next(next);229});230factor.add_word("kernel", "swap", "primitive", function(next) {231 var stack = factor.cont.data_stack;232 var temp = stack[stack.length-2];233 stack[stack.length-2] = stack[stack.length-1];234 stack[stack.length-1] = temp;235 factor.call_next(next);236});237factor.add_word("kernel", ">r", "primitive", function(next) {238 var data_stack = factor.cont.data_stack;239 var retain_stack = factor.cont.retain_stack;240 retain_stack.push(data_stack.pop());241 factor.call_next(next);242});243factor.add_word("kernel", "r>", "primitive", function(next) {244 var data_stack = factor.cont.data_stack;245 var retain_stack = factor.cont.retain_stack;246 data_stack.push(retain_stack.pop());247 factor.call_next(next);248});249factor.add_word("kernel", "call", "primitive", function(next) {250 var quot = factor.cont.data_stack.pop();251 quot.execute(next);252});253factor.add_word("kernel", "execute", "primitive", function(next) {254 var quot = factor.cont.data_stack.pop();255 quot.execute(next);256});257factor.add_word("kernel", "clear", "primitive", function(next) {258 factor.cont.data_stack = [];259 factor.cont.retain_stack = [];260 factor.call_next(next);261});262factor.add_word("kernel", "if", "primitive", function(next) { 263 var stack = factor.cont.data_stack;264 var else_quot = stack.pop();265 var then_quot = stack.pop();266 var condition = stack.pop();267 if(condition) {268 then_quot.execute(next);269 } else {270 else_quot.execute(next);271 }272});273factor.add_word("kernel", "f", "primitive", function(next) { 274 factor.cont.data_stack.push(false);275 factor.call_next(next);276});277factor.add_word("kernel", "t", "primitive", function(next) { 278 factor.cont.data_stack.push(true);279 factor.call_next(next);280});281factor.add_word("kernel", "=", "primitive", function(next) { 282 var stack = factor.cont.data_stack;283 stack.push(stack.pop()==stack.pop());284 factor.call_next(next);285});286factor.add_word("kernel", "bootstrap", "primitive", function(next) { 287 factor.cont.data_stack.push("/responder/fjsc-resources/bootstrap.factor");288 factor.get_word("parser", "run-file").execute(next);289});290factor.add_word("kernel", "callcc0", "primitive", function(next) { 291 var data_stack = factor.cont.data_stack;292 var quot = data_stack.pop();293 var new_cont = factor.cont.clone(); 294 var old_next = factor.cont.next;295 factor.cont.next = function() {296 factor.cont.next = old_next;297 factor.call_next(next);298 }299 new_cont.data_stack.push(factor.cont);300 factor.cont = new_cont;301 quot.execute(next); 302});303factor.add_word("kernel", "callcc1", "primitive", function(next) { 304 factor.get_word("kernel", "callcc0").execute(next);305});306factor.add_word("kernel", "continue", "primitive", function(next) { 307 var data_stack = factor.cont.data_stack;308 var cont = data_stack.pop(); 309 factor.cont = cont.clone();310 factor.call_next(cont.next);311});312factor.add_word("kernel", "continue-with", "primitive", function(next) { 313 var data_stack = factor.cont.data_stack;314 var cont = data_stack.pop(); 315 var data = data_stack.pop(); 316 factor.cont = cont.clone();317 factor.cont.data_stack.push(data);318 factor.call_next(cont.next);319});320factor.add_word("kernel", "set-in", "primitive", function(next) { 321 var stack = factor.cont.data_stack;322 var vocab = stack.pop();323 var v = factor.vocabs[vocab];324 if(!v) {325 v = { };326 factor.vocabs[vocab] = v;327 }328 factor.in_vocab = vocab;329 factor.call_next(next); 330});331factor.add_word("kernel", "current-vocab", "primitive", function(next) { 332 var stack = factor.cont.data_stack;333 stack.push(factor.in_vocab);334 factor.call_next(next); 335});336factor.add_word("kernel", "use+", "primitive", function(next) { 337 var stack = factor.cont.data_stack;338 var vocab = stack.pop();339 var v = factor.vocabs[vocab];340 if(!v) {341 v = { };342 factor.vocabs[vocab] = v;343 }344 factor.using_vocabs.push(vocab);345 factor.call_next(next); 346});347factor.add_word("kernel", "using", "primitive", function(next) { 348 var stack = factor.cont.data_stack;349 var vocabs = stack.pop();350 for(var i=0;i<vocabs.length;++i) { 351 var v = factor.vocabs[vocabs[i]];352 if(!v) {353 v = { };354 factor.vocabs[vocabs[i]] = v;355 }356 factor.using_vocabs.push(vocabs[i]);357 }358 factor.call_next(next); 359});360factor.add_word("kernel", "current-using", "primitive", function(next) { 361 var stack = factor.cont.data_stack;362 stack.push(factor.using_vocabs);363 factor.call_next(next); 364});365factor.add_word("kernel", "forget", "primitive", function(next) { 366 var stack = factor.cont.data_stack;367 var word = stack.pop();368 factor.remove_word(word.vocab, word.name);369 factor.call_next(next); 370});371factor.add_word("kernel", ">function", "primitive", function(next) { 372 var stack = factor.cont.data_stack;373 var word = stack.pop();374 stack.push(function() { word.func(function() { }) });375 factor.call_next(next); 376});377factor.add_word("kernel", "curry", "primitive", function(next) { 378 var stack = factor.cont.data_stack;379 var quot = stack.pop();380 var value = stack.pop();381 382 stack.push(factor.make_quotation("quotation", function(next) {383 factor.cont.data_stack.push(value); 384 quot.execute(factor.cont.next);385 }));386 factor.call_next(next);387});388/* Math vocabulary */389factor.add_word("math", "*", "primitive", function(next) {390 var stack = factor.cont.data_stack;391 stack.push(stack.pop() * stack.pop());392 factor.call_next(next);393});394factor.add_word("math", "+", "primitive", function(next) {395 var stack = factor.cont.data_stack;396 stack.push(stack.pop() + stack.pop());397 factor.call_next(next);398});399factor.add_word("math", "-", "primitive", function(next) {400 var stack = factor.cont.data_stack;401 var v1 = stack.pop();402 var v2 = stack.pop();403 stack.push(v2 - v1);404 factor.call_next(next);405});406factor.add_word("math", "/", "primitive", function(next) {407 var stack = factor.cont.data_stack;408 var v1 = stack.pop();409 var v2 = stack.pop();410 stack.push(v2 / v1);411 factor.call_next(next);412});413factor.add_word("parser", "run-file", "primitive", function(next) { 414 var stack = factor.cont.data_stack;415 var url = stack.pop();416 $.get(url, function(result) {417 factor.server_eval(result, function() { }, next);418 });419});420factor.add_word("alien", "alien-invoke", "primitive", function(next) { 421 var stack = factor.cont.data_stack;422 var arg_types = stack.pop();423 var method_name = stack.pop();424 var library_name = stack.pop();425 var return_values = stack.pop();426 var obj = stack.pop();427 var args = [ ];428 for(var i = 0; i < arg_types.length; ++i) {429 args[i] = stack.pop();430 }431 var func = obj[method_name];432 if(method_name=="alert") {433 func = function(a) { alert(a); }434 }435 var v = func.apply(obj, args.reverse());436 if(return_values.length > 0)437 stack.push(v);438 factor.call_next(next);439});440factor.add_word("alien", "alien-property", "primitive", function(next) { 441 var stack = factor.cont.data_stack;442 var obj = stack.pop();443 var property_name = stack.pop();444 var v = obj[property_name];445 stack.push(v);446 factor.call_next(next);447});448factor.add_word("alien", "set-alien-property", "primitive", function(next) { 449 var stack = factor.cont.data_stack;450 var obj = stack.pop();451 var property_name = stack.pop();452 var data = stack.pop();453 obj[property_name] = v;454 factor.call_next(next);455});456factor.add_word("alien", "uneval", "primitive", function(next) {457 var stack = factor.cont.data_stack;458 stack.push(uneval(stack.pop()));459 factor.call_next(next);460});461factor.add_word("words", "vocabs", "primitive", function(next) { 462 var stack = factor.cont.data_stack;463 var result = [];464 for(v in factor.vocabs) {465 result.push(v);466 }467 stack.push(result);468 factor.call_next(next);469});470factor.add_word("words", "words", "primitive", function(next) { 471 var stack = factor.cont.data_stack;472 var vocab = factor.vocabs[stack.pop()];473 var result = [];474 for(w in vocab) {475 result.push(vocab[w]);476 }477 stack.push(result);478 factor.call_next(next);479});480factor.add_word("words", "all-words", "primitive", function(next) { 481 var stack = factor.cont.data_stack;482 var result = [];483 for(v in factor.vocabs) {484 for(w in factor.vocabs[v]) {485 result.push(factor.vocabs[v][w]);486 }487 }488 stack.push(result);489 factor.call_next(next);490});491/* Sequences vocabulary */492factor.add_word("sequences", "nth", "primitive", function(next) { 493 var stack = factor.cont.data_stack;494 var seq = stack.pop();495 var index = stack.pop();496 stack.push(seq[index]);497 factor.call_next(next);498});499factor.add_word("sequences", "first", "primitive", function(next) { 500 var stack = factor.cont.data_stack;501 var seq = stack.pop();502 stack.push(seq[0]);503 factor.call_next(next);504});505factor.add_word("sequences", "second", "primitive", function(next) { 506 var stack = factor.cont.data_stack;507 var seq = stack.pop();508 stack.push(seq[1]);509 factor.call_next(next);510});511factor.add_word("sequences", "third", "primitive", function(next) { 512 var stack = factor.cont.data_stack;513 var seq = stack.pop();514 stack.push(seq[2]);515 factor.call_next(next);516});517factor.add_word("sequences", "fourth", "primitive", function(next) { 518 var stack = factor.cont.data_stack;519 var seq = stack.pop();520 stack.push(seq[0]);521 factor.call_next(next);522});523factor.add_word("sequences", "first2", "primitive", function(next) { 524 var stack = factor.cont.data_stack;525 var seq = stack.pop();526 stack.push(seq[0],seq[1]);527 factor.call_next(next);528});529factor.add_word("sequences", "first3", "primitive", function(next) { 530 var stack = factor.cont.data_stack;531 var seq = stack.pop();532 stack.push(seq[0],seq[1],seq[2]);533 factor.call_next(next);534});535factor.add_word("sequences", "first4", "primitive", function(next) { 536 var stack = factor.cont.data_stack;537 var seq = stack.pop();538 stack.push(seq[0],seq[1],seq[2],seq[3]);539 factor.call_next(next);540});541factor.add_word("sequences", "each", "primitive", function(next) { 542 var stack = factor.cont.data_stack;543 var quot = stack.pop();544 var seq = stack.pop();545 for(var i=0;i<seq.length;++i) { 546 stack.push(seq[i]);547 quot.execute();548 }549 factor.call_next(next);550});551factor.add_word("sequences", "map", "primitive", function(next) { 552 var stack = factor.cont.data_stack;553 var quot = stack.pop();554 var seq = stack.pop();555 var result = [ ];556 for(var i=0;i<seq.length;++i) { 557 stack.push(seq[i]);558 quot.execute();559 result[i]=stack.pop();560 }561 stack.push(result);562 factor.call_next(next);563});564factor.add_word("sequences", "reduce", "primitive", function(next) { 565 var stack = factor.cont.data_stack;566 var quot = stack.pop();567 var prev = stack.pop();568 var seq = stack.pop();569 for(var i=0;i<seq.length;++i) { 570 stack.push(prev);571 stack.push(seq[i]);572 quot.execute();573 prev=stack.pop();Al574 }575 stack.push(prev);576 factor.call_next(next);577});578/* hashtables vocabulary */579factor.add_word("hashtables", "alist>hash", "primitive", function(next) { 580 var stack = factor.cont.data_stack;581 var alist = stack.pop();582 stack.push(new Hashtable().fromAlist(alist));583 factor.call_next(next);584});585factor.add_word("hashtables", "hash>alist", "primitive", function(next) { 586 var stack = factor.cont.data_stack;587 var hashtable = stack.pop();588 stack.push(hashtable.toAlist());589 factor.call_next(next);590});591factor.add_word("hashtables", "hash", "primitive", function(next) { 592 var stack = factor.cont.data_stack;593 var hashtable = stack.pop();594 var key = stack.pop();595 stack.push(hashtable.get(key));596 factor.call_next(next);597});598factor.add_word("hashtables", "set-hash", "primitive", function(next) { 599 var stack = factor.cont.data_stack;600 var hashtable = stack.pop();601 var key = stack.pop();602 var value = stack.pop();603 hashtable.set(key, value);604 factor.call_next(next);605});606factor.add_word("sequences", "hash-each", "primitive", function(next) { 607 var stack = factor.cont.data_stack;608 var quot = stack.pop();609 var hashtable = stack.pop().table;610 for(k in hashtable) { 611 var v = hashtable[k]; 612 stack.push(k, v);613 quot.execute();614 }615 factor.call_next(next);616});617factor.add_word("sequences", "hash-map", "primitive", function(next) { 618 var stack = factor.cont.data_stack;619 var quot = stack.pop();620 var hashtable = stack.pop().table;621 var result = [ ];622 for(k in hashtable) { 623 var v = hashtable[k];624 stack.push(k,v);625 quot.execute();626 result.push(stack.pop());627 }628 stack.push(result);629 factor.call_next(next);630});631/* browser-dom vocab */632factor.add_word("browser-dom", "window", "primitive", function(next) { 633 factor.cont.data_stack.push(window);634 factor.call_next(next);635});636factor.add_word("browser-dom", "document", "primitive", function(next) { 637 factor.cont.data_stack.push(document);638 factor.call_next(next);639});640factor.add_word("browser-dom", "load-script", "primitive", function(next) { 641 var stack = factor.cont.data_stack;642 $("head/script#jsonrequest").remove();643 var script = document.createElement("script");644 script.id = "jsonrequest"; 645 script.type = "text/javascript";646 script.src = stack.pop();647 $("head").append(script);648 factor.call_next(next); 649});650var handle_json = false;651factor.add_word("browser-dom", "json-request", "primitive", function(next) { 652 var stack = factor.cont.data_stack;653 handle_json = function(data) { 654 factor.cont.data_stack.push(data);655 factor.call_next(next);656 }657 factor.get_word("browser-dom", "load-script").execute();...
App.js
Source:App.js
1import React, { useState, useEffect } from "react";2import { StyleSheet } from "react-native";3import { Ionicons } from "@expo/vector-icons";4import { FontAwesome } from "@expo/vector-icons";5import { AntDesign } from "@expo/vector-icons";6import { AsyncStorage } from "react-native";7import { NavigationContainer } from "@react-navigation/native";8import { createStackNavigator } from "@react-navigation/stack";9import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";10const Stack = createStackNavigator();11const Tab = createBottomTabNavigator();12// Import des composants :13import Home from "./screens/Home";14import Login from "./screens/Login";15import Message from "./screens/Message";16import ProfileMenu from "./screens/ProfileMenu";17import Profile from "./screens/Profile";18import Search from "./screens/Search";19import SearchArticle from "./components/SearchArticle";20import SearchUser from "./components/SearchUser";21import Signup from "./screens/Signup";22import Annonce from "./components/Annonce";23import Acheter from "./screens/Acheter";24import ProfileVendeur from "./screens/ProfileVendeur";25import Vendre from "./screens/Vendre";26import DeleteAccount from "./components/DeleteAccount";27import Commandes from "./screens/Commandes";28import Dressing from "./screens/Dressing";29import Evaluations from "./screens/Evaluations";30import Ventes from "./screens/Ventes";31import Favoris from "./screens/Favoris";32import FAQ from "./screens/FAQ";33import FaqVendre from "./components/FaqVendre";34import FaqAcheter from "./components/FaqAcheter";35import FaqCommunaute from "./components/FaqCommunaute";36import DeleteAdd from "./components/DeleteAdd";37import UpdateAdd from "./components/UpdateAdd";38import Formulaire from "./components/Formulaire";39// Fin Import des composants40export default function App() {41 const [isLoading, setisLoading] = useState(true);42 const [userToken, setUserToken] = useState(null);43 const [userId, setUserId] = useState(null);44 const [favoris, setFavoris] = useState([]);45 const setToken = async (token) => {46 if (token) {47 AsyncStorage.setItem("userToken", token);48 } else {49 AsyncStorage.removeItem("userToken");50 }51 setUserToken(token);52 };53 const setId = async (id) => {54 if (id) {55 AsyncStorage.setItem("userId", id);56 } else {57 AsyncStorage.removeItem("userId");58 }59 setUserId(id);60 };61 useEffect(() => {62 const bootstrapAsync = async () => {63 const userToken = await AsyncStorage.getItem("userToken");64 setisLoading(false);65 setUserToken(userToken);66 };67 bootstrapAsync();68 }, []);69 return (70 <NavigationContainer>71 {isLoading ? null : userToken === null ? (72 <Stack.Navigator>73 <Stack.Screen name="Login">74 {() => <Login setId={setId} setToken={setToken} />}75 </Stack.Screen>76 <Stack.Screen name="Signup">77 {() => <Signup setId={setId} setToken={setToken} />}78 </Stack.Screen>79 </Stack.Navigator>80 ) : (81 <Stack.Navigator>82 <Stack.Screen83 name="Menu"84 options={{ header: () => null, animationEnabled: false }}85 >86 {() => (87 <Tab.Navigator88 tabBarOptions={{89 style: {90 backgroundColor: "white",91 height: "14%",92 },93 }}94 >95 <Tab.Screen96 name="Home"97 options={{98 tabBarLabel: "Home",99 tabBarIcon: () => (100 <Ionicons name={"ios-home"} size={32} color="#C63E81" />101 ),102 }}103 >104 {() => (105 <Stack.Navigator>106 <Stack.Screen107 options={{108 title: "Fil d'actualité",109 headerShown: true,110 }}111 name="Home"112 >113 {() => (114 <Home115 favoris={favoris}116 setFavoris={setFavoris}117 userToken={userToken}118 />119 )}120 </Stack.Screen>121 <Stack.Screen122 name="Annonce"123 options={{124 title: "Annonce",125 headerShown: true,126 }}127 >128 {() => (129 <Annonce130 favoris={favoris}131 setFavoris={setFavoris}132 userToken={userToken}133 />134 )}135 </Stack.Screen>136 <Stack.Screen137 name="Dressing"138 options={{139 title: "Mon Dressing",140 headerShown: true,141 }}142 >143 {() => <Dressing setId={setId} setToken={setToken} />}144 </Stack.Screen>145 <Stack.Screen146 name="Acheter"147 options={{148 title: "Acheter",149 headerShown: true,150 }}151 >152 {() => <Acheter />}153 </Stack.Screen>154 <Stack.Screen155 name="ProfileVendeur"156 options={{157 title: "Profil du vendeur",158 headerShown: true,159 }}160 >161 {() => <ProfileVendeur />}162 </Stack.Screen>163 </Stack.Navigator>164 )}165 </Tab.Screen>166 <Tab.Screen167 name="Vendre"168 options={{169 tabBarLabel: "Vendre",170 tabBarIcon: () => (171 <AntDesign name="pluscircleo" size={30} color="#C63E81" />172 ),173 }}174 >175 {() => (176 <Stack.Navigator>177 <Stack.Screen178 name="Vendre"179 options={{180 title: "Vendre un article",181 headerShown: true,182 }}183 >184 {() => <Vendre />}185 </Stack.Screen>186 <Stack.Screen187 name="Dressing"188 options={{189 title: "Mon Dressing",190 headerShown: true,191 }}192 >193 {() => <Dressing setId={setId} setToken={setToken} />}194 </Stack.Screen>195 </Stack.Navigator>196 )}197 </Tab.Screen>198 <Tab.Screen199 name="Profile"200 options={{201 tabBarLabel: "Profile",202 tabBarIcon: () => (203 <Ionicons name={"ios-person"} size={40} color="#C63E81" />204 ),205 }}206 >207 {() => (208 <Stack.Navigator>209 <Stack.Screen210 name="ProfileMenu"211 options={{212 title: "Mon Profile",213 headerShown: true,214 }}215 >216 {() => (217 <ProfileMenu setId={setId} setToken={setToken} />218 )}219 </Stack.Screen>220 <Stack.Screen221 name="Profile"222 options={{223 title: "Mes informations personnelles",224 headerShown: true,225 }}226 >227 {() => <Profile setId={setId} setToken={setToken} />}228 </Stack.Screen>229 <Stack.Screen230 name="DeleteAccount"231 options={{232 title: "Supprimer mon compte",233 headerShown: true,234 }}235 >236 {() => (237 <DeleteAccount setId={setId} setToken={setToken} />238 )}239 </Stack.Screen>240 <Stack.Screen241 name="Commandes"242 options={{243 title: "Mes commandes",244 headerShown: true,245 }}246 >247 {() => <Commandes setId={setId} setToken={setToken} />}248 </Stack.Screen>249 <Stack.Screen250 name="Ventes"251 options={{252 title: "Mes ventes",253 headerShown: true,254 }}255 >256 {() => <Ventes setId={setId} setToken={setToken} />}257 </Stack.Screen>258 <Stack.Screen259 name="ProfileVendeur"260 options={{261 title: "Profil du vendeur",262 headerShown: true,263 }}264 >265 {() => <ProfileVendeur />}266 </Stack.Screen>267 <Stack.Screen268 name="Dressing"269 options={{270 title: "Mon Dressing",271 headerShown: true,272 }}273 >274 {() => <Dressing setId={setId} setToken={setToken} />}275 </Stack.Screen>276 <Stack.Screen277 name="DeleteAdd"278 options={{279 title: "Supprimer une annonce",280 headerShown: true,281 }}282 >283 {() => <DeleteAdd />}284 </Stack.Screen>285 <Stack.Screen286 name="UpdateAdd"287 options={{288 title: "Modifier une annonce",289 headerShown: true,290 }}291 >292 {() => <UpdateAdd />}293 </Stack.Screen>294 <Stack.Screen295 name="Evaluations"296 options={{297 title: "Mes évaluations",298 headerShown: true,299 }}300 >301 {() => <Evaluations />}302 </Stack.Screen>303 <Stack.Screen304 name="Favoris"305 options={{306 title: "Mes favoris",307 headerShown: true,308 }}309 >310 {() => (311 <Favoris favoris={favoris} setFavoris={setFavoris} />312 )}313 </Stack.Screen>314 <Stack.Screen315 name="Annonce"316 options={{317 title: "Annonce",318 headerShown: true,319 }}320 >321 {() => (322 <Annonce favoris={favoris} setFavoris={setFavoris} />323 )}324 </Stack.Screen>325 <Stack.Screen326 name="FAQ"327 options={{328 title: "Comment est ce que ça marche ?",329 headerShown: true,330 }}331 >332 {() => <FAQ />}333 </Stack.Screen>334 <Stack.Screen335 name="FaqVendre"336 options={{337 title: "Comment vendre mon article ?",338 headerShown: true,339 }}340 >341 {() => <FaqVendre />}342 </Stack.Screen>343 <Stack.Screen344 name="FaqAcheter"345 options={{346 title: "Comment acheter un article ?",347 headerShown: true,348 }}349 >350 {() => <FaqAcheter />}351 </Stack.Screen>352 <Stack.Screen353 name="FaqCommunaute"354 options={{355 title: "La communauté SyMa",356 headerShown: true,357 }}358 >359 {() => <FaqCommunaute />}360 </Stack.Screen>361 <Stack.Screen362 name="Formulaire"363 options={{364 title: "Nous contacter",365 headerShown: true,366 }}367 >368 {() => <Formulaire />}369 </Stack.Screen>370 </Stack.Navigator>371 )}372 </Tab.Screen>373 <Tab.Screen374 name="Message"375 options={{376 tabBarLabel: "Message",377 tabBarIcon: () => (378 <FontAwesome379 name="envelope-o"380 size={30}381 color="#C63E81"382 />383 ),384 }}385 >386 {() => (387 <Stack.Navigator>388 <Stack.Screen389 name="Message"390 options={{391 title: "Message",392 headerShown: true,393 }}394 >395 {() => <Message />}396 </Stack.Screen>397 </Stack.Navigator>398 )}399 </Tab.Screen>400 <Tab.Screen401 name="Search"402 options={{403 tabBarLabel: "Search",404 tabBarIcon: () => (405 <FontAwesome name="search" size={30} color="#C63E81" />406 ),407 }}408 >409 {() => (410 <Stack.Navigator>411 <Stack.Screen412 name="Search"413 options={{414 title: "Rechercher",415 headerShown: true,416 }}417 >418 {() => <Search />}419 </Stack.Screen>420 <Stack.Screen421 name="SearchArticle"422 options={{423 title: "Rechercher un article",424 headerShown: true,425 }}426 >427 {() => <SearchArticle />}428 </Stack.Screen>429 <Stack.Screen430 name="SearchUser"431 options={{432 title: "Rechercher un membre",433 headerShown: true,434 }}435 >436 {() => <SearchUser />}437 </Stack.Screen>438 <Stack.Screen439 name="ProfileVendeur"440 options={{441 title: "Profil du vendeur",442 headerShown: true,443 }}444 >445 {() => <ProfileVendeur />}446 </Stack.Screen>447 </Stack.Navigator>448 )}449 </Tab.Screen>450 </Tab.Navigator>451 )}452 </Stack.Screen>453 </Stack.Navigator>454 )}455 </NavigationContainer>456 );457}458const styles = StyleSheet.create({459 container: {460 flex: 1,461 backgroundColor: "#fff",462 alignItems: "center",463 justifyContent: "center",464 },...
InsideStack.js
Source:InsideStack.js
1import React from 'react';2import { I18nManager } from 'react-native';3import { createStackNavigator } from '@react-navigation/stack';4import { createDrawerNavigator } from '@react-navigation/drawer';5import { ThemeContext } from '../theme';6import {7 defaultHeader, themedHeader, ModalAnimation, StackAnimation8} from '../utils/navigation';9import Sidebar from '../views/SidebarView';10// Chats Stack11import RoomView from '../views/RoomView';12import RoomsListView from '../views/RoomsListView';13import RoomActionsView from '../views/RoomActionsView';14import RoomInfoView from '../views/RoomInfoView';15import RoomInfoEditView from '../views/RoomInfoEditView';16import RoomMembersView from '../views/RoomMembersView';17import SearchMessagesView from '../views/SearchMessagesView';18import SelectedUsersView from '../views/SelectedUsersView';19import InviteUsersView from '../views/InviteUsersView';20import InviteUsersEditView from '../views/InviteUsersEditView';21import MessagesView from '../views/MessagesView';22import AutoTranslateView from '../views/AutoTranslateView';23import DirectoryView from '../views/DirectoryView';24import NotificationPrefView from '../views/NotificationPreferencesView';25import VisitorNavigationView from '../views/VisitorNavigationView';26import ForwardLivechatView from '../views/ForwardLivechatView';27import LivechatEditView from '../views/LivechatEditView';28import PickerView from '../views/PickerView';29import ThreadMessagesView from '../views/ThreadMessagesView';30import TeamChannelsView from '../views/TeamChannelsView';31import MarkdownTableView from '../views/MarkdownTableView';32import ReadReceiptsView from '../views/ReadReceiptView';33import { themes } from '../constants/colors';34// Profile Stack35import ProfileView from '../views/ProfileView';36import UserPreferencesView from '../views/UserPreferencesView';37import UserNotificationPrefView from '../views/UserNotificationPreferencesView';38// Settings Stack39import SettingsView from '../views/SettingsView';40import SecurityPrivacyView from '../views/SecurityPrivacyView';41import E2EEncryptionSecurityView from '../views/E2EEncryptionSecurityView';42import LanguageView from '../views/LanguageView';43import ThemeView from '../views/ThemeView';44import DefaultBrowserView from '../views/DefaultBrowserView';45import ScreenLockConfigView from '../views/ScreenLockConfigView';46// Admin Stack47import AdminPanelView from '../views/AdminPanelView';48// NewMessage Stack49import NewMessageView from '../views/NewMessageView';50import CreateChannelView from '../views/CreateChannelView';51// E2ESaveYourPassword Stack52import E2ESaveYourPasswordView from '../views/E2ESaveYourPasswordView';53import E2EHowItWorksView from '../views/E2EHowItWorksView';54// E2EEnterYourPassword Stack55import E2EEnterYourPasswordView from '../views/E2EEnterYourPasswordView';56// InsideStackNavigator57import AttachmentView from '../views/AttachmentView';58import ModalBlockView from '../views/ModalBlockView';59import JitsiMeetView from '../views/JitsiMeetView';60import StatusView from '../views/StatusView';61import ShareView from '../views/ShareView';62import CreateDiscussionView from '../views/CreateDiscussionView';63import QueueListView from '../ee/omnichannel/views/QueueListView';64import AddChannelTeamView from '../views/AddChannelTeamView';65import AddExistingChannelView from '../views/AddExistingChannelView';66import SelectListView from '../views/SelectListView';67// ChatsStackNavigator68const ChatsStack = createStackNavigator();69const ChatsStackNavigator = () => {70 const { theme } = React.useContext(ThemeContext);71 return (72 <ChatsStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>73 <ChatsStack.Screen74 name='RoomsListView'75 component={RoomsListView}76 />77 <ChatsStack.Screen78 name='RoomView'79 component={RoomView}80 />81 <ChatsStack.Screen82 name='RoomActionsView'83 component={RoomActionsView}84 options={RoomActionsView.navigationOptions}85 />86 <ChatsStack.Screen87 name='SelectListView'88 component={SelectListView}89 options={SelectListView.navigationOptions}90 />91 <ChatsStack.Screen92 name='RoomInfoView'93 component={RoomInfoView}94 options={RoomInfoView.navigationOptions}95 />96 <ChatsStack.Screen97 name='RoomInfoEditView'98 component={RoomInfoEditView}99 options={RoomInfoEditView.navigationOptions}100 />101 <ChatsStack.Screen102 name='RoomMembersView'103 component={RoomMembersView}104 options={RoomMembersView.navigationOptions}105 />106 <ChatsStack.Screen107 name='SearchMessagesView'108 component={SearchMessagesView}109 options={SearchMessagesView.navigationOptions}110 />111 <ChatsStack.Screen112 name='SelectedUsersView'113 component={SelectedUsersView}114 />115 <ChatsStack.Screen116 name='InviteUsersView'117 component={InviteUsersView}118 options={InviteUsersView.navigationOptions}119 />120 <ChatsStack.Screen121 name='InviteUsersEditView'122 component={InviteUsersEditView}123 options={InviteUsersEditView.navigationOptions}124 />125 <ChatsStack.Screen126 name='MessagesView'127 component={MessagesView}128 />129 <ChatsStack.Screen130 name='AutoTranslateView'131 component={AutoTranslateView}132 options={AutoTranslateView.navigationOptions}133 />134 <ChatsStack.Screen135 name='DirectoryView'136 component={DirectoryView}137 options={DirectoryView.navigationOptions}138 />139 <ChatsStack.Screen140 name='NotificationPrefView'141 component={NotificationPrefView}142 options={NotificationPrefView.navigationOptions}143 />144 <ChatsStack.Screen145 name='VisitorNavigationView'146 component={VisitorNavigationView}147 options={VisitorNavigationView.navigationOptions}148 />149 <ChatsStack.Screen150 name='ForwardLivechatView'151 component={ForwardLivechatView}152 options={ForwardLivechatView.navigationOptions}153 />154 <ChatsStack.Screen155 name='LivechatEditView'156 component={LivechatEditView}157 options={LivechatEditView.navigationOptions}158 />159 <ChatsStack.Screen160 name='PickerView'161 component={PickerView}162 options={PickerView.navigationOptions}163 />164 <ChatsStack.Screen165 name='ThreadMessagesView'166 component={ThreadMessagesView}167 options={ThreadMessagesView.navigationOptions}168 />169 <ChatsStack.Screen170 name='TeamChannelsView'171 component={TeamChannelsView}172 options={TeamChannelsView.navigationOptions}173 />174 <ChatsStack.Screen175 name='CreateChannelView'176 component={CreateChannelView}177 options={CreateChannelView.navigationOptions}178 />179 <ChatsStack.Screen180 name='AddChannelTeamView'181 component={AddChannelTeamView}182 options={AddChannelTeamView.navigationOptions}183 />184 <ChatsStack.Screen185 name='AddExistingChannelView'186 component={AddExistingChannelView}187 options={AddExistingChannelView.navigationOptions}188 />189 <ChatsStack.Screen190 name='MarkdownTableView'191 component={MarkdownTableView}192 options={MarkdownTableView.navigationOptions}193 />194 <ChatsStack.Screen195 name='ReadReceiptsView'196 component={ReadReceiptsView}197 options={ReadReceiptsView.navigationOptions}198 />199 <ChatsStack.Screen200 name='QueueListView'201 component={QueueListView}202 options={QueueListView.navigationOptions}203 />204 </ChatsStack.Navigator>205 );206};207// ProfileStackNavigator208const ProfileStack = createStackNavigator();209const ProfileStackNavigator = () => {210 const { theme } = React.useContext(ThemeContext);211 return (212 <ProfileStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>213 <ProfileStack.Screen214 name='ProfileView'215 component={ProfileView}216 options={ProfileView.navigationOptions}217 />218 <ProfileStack.Screen219 name='UserPreferencesView'220 component={UserPreferencesView}221 options={UserPreferencesView.navigationOptions}222 />223 <ProfileStack.Screen224 name='UserNotificationPrefView'225 component={UserNotificationPrefView}226 options={UserNotificationPrefView.navigationOptions}227 />228 <ProfileStack.Screen229 name='PickerView'230 component={PickerView}231 options={PickerView.navigationOptions}232 />233 </ProfileStack.Navigator>234 );235};236// SettingsStackNavigator237const SettingsStack = createStackNavigator();238const SettingsStackNavigator = () => {239 const { theme } = React.useContext(ThemeContext);240 return (241 <SettingsStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>242 <SettingsStack.Screen243 name='SettingsView'244 component={SettingsView}245 options={SettingsView.navigationOptions}246 />247 <SettingsStack.Screen248 name='SecurityPrivacyView'249 component={SecurityPrivacyView}250 options={SecurityPrivacyView.navigationOptions}251 />252 <SettingsStack.Screen253 name='E2EEncryptionSecurityView'254 component={E2EEncryptionSecurityView}255 options={E2EEncryptionSecurityView.navigationOptions}256 />257 <SettingsStack.Screen258 name='LanguageView'259 component={LanguageView}260 options={LanguageView.navigationOptions}261 />262 <SettingsStack.Screen263 name='ThemeView'264 component={ThemeView}265 options={ThemeView.navigationOptions}266 />267 <SettingsStack.Screen268 name='DefaultBrowserView'269 component={DefaultBrowserView}270 options={DefaultBrowserView.navigationOptions}271 />272 <SettingsStack.Screen273 name='ScreenLockConfigView'274 component={ScreenLockConfigView}275 options={ScreenLockConfigView.navigationOptions}276 />277 </SettingsStack.Navigator>278 );279};280// AdminPanelStackNavigator281const AdminPanelStack = createStackNavigator();282const AdminPanelStackNavigator = () => {283 const { theme } = React.useContext(ThemeContext);284 return (285 <AdminPanelStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>286 <AdminPanelStack.Screen287 name='AdminPanelView'288 component={AdminPanelView}289 options={AdminPanelView.navigationOptions}290 />291 </AdminPanelStack.Navigator>292 );293};294// DrawerNavigator295const Drawer = createDrawerNavigator();296const DrawerNavigator = () => {297 const { theme } = React.useContext(ThemeContext);298 return (299 <Drawer.Navigator300 drawerContent={({ navigation, state }) => <Sidebar navigation={navigation} state={state} />}301 drawerPosition={I18nManager.isRTL ? 'right' : 'left'}302 screenOptions={{ swipeEnabled: false }}303 drawerType='back'304 overlayColor={`rgba(0,0,0,${ themes[theme].backdropOpacity })`}305 >306 <Drawer.Screen name='ChatsStackNavigator' component={ChatsStackNavigator} />307 <Drawer.Screen name='ProfileStackNavigator' component={ProfileStackNavigator} />308 <Drawer.Screen name='SettingsStackNavigator' component={SettingsStackNavigator} />309 <Drawer.Screen name='AdminPanelStackNavigator' component={AdminPanelStackNavigator} />310 </Drawer.Navigator>311 );312};313// NewMessageStackNavigator314const NewMessageStack = createStackNavigator();315const NewMessageStackNavigator = () => {316 const { theme } = React.useContext(ThemeContext);317 return (318 <NewMessageStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>319 <NewMessageStack.Screen320 name='NewMessageView'321 component={NewMessageView}322 options={NewMessageView.navigationOptions}323 />324 <NewMessageStack.Screen325 name='SelectedUsersViewCreateChannel'326 component={SelectedUsersView}327 />328 <NewMessageStack.Screen329 name='CreateChannelView'330 component={CreateChannelView}331 options={CreateChannelView.navigationOptions}332 />333 <NewMessageStack.Screen334 name='CreateDiscussionView'335 component={CreateDiscussionView}336 />337 </NewMessageStack.Navigator>338 );339};340// E2ESaveYourPasswordStackNavigator341const E2ESaveYourPasswordStack = createStackNavigator();342const E2ESaveYourPasswordStackNavigator = () => {343 const { theme } = React.useContext(ThemeContext);344 return (345 <E2ESaveYourPasswordStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>346 <E2ESaveYourPasswordStack.Screen347 name='E2ESaveYourPasswordView'348 component={E2ESaveYourPasswordView}349 options={E2ESaveYourPasswordView.navigationOptions}350 />351 <E2ESaveYourPasswordStack.Screen352 name='E2EHowItWorksView'353 component={E2EHowItWorksView}354 options={E2EHowItWorksView.navigationOptions}355 />356 </E2ESaveYourPasswordStack.Navigator>357 );358};359// E2EEnterYourPasswordStackNavigator360const E2EEnterYourPasswordStack = createStackNavigator();361const E2EEnterYourPasswordStackNavigator = () => {362 const { theme } = React.useContext(ThemeContext);363 return (364 <E2EEnterYourPasswordStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>365 <E2EEnterYourPasswordStack.Screen366 name='E2EEnterYourPasswordView'367 component={E2EEnterYourPasswordView}368 options={E2EEnterYourPasswordView.navigationOptions}369 />370 </E2EEnterYourPasswordStack.Navigator>371 );372};373// InsideStackNavigator374const InsideStack = createStackNavigator();375const InsideStackNavigator = () => {376 const { theme } = React.useContext(ThemeContext);377 return (378 <InsideStack.Navigator mode='modal' screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...ModalAnimation }}>379 <InsideStack.Screen380 name='DrawerNavigator'381 component={DrawerNavigator}382 options={{ headerShown: false }}383 />384 <InsideStack.Screen385 name='NewMessageStackNavigator'386 component={NewMessageStackNavigator}387 options={{ headerShown: false }}388 />389 <InsideStack.Screen390 name='E2ESaveYourPasswordStackNavigator'391 component={E2ESaveYourPasswordStackNavigator}392 options={{ headerShown: false }}393 />394 <InsideStack.Screen395 name='E2EEnterYourPasswordStackNavigator'396 component={E2EEnterYourPasswordStackNavigator}397 options={{ headerShown: false }}398 />399 <InsideStack.Screen400 name='AttachmentView'401 component={AttachmentView}402 />403 <InsideStack.Screen404 name='StatusView'405 component={StatusView}406 />407 <InsideStack.Screen408 name='ShareView'409 component={ShareView}410 />411 <InsideStack.Screen412 name='ModalBlockView'413 component={ModalBlockView}414 options={ModalBlockView.navigationOptions}415 />416 <InsideStack.Screen417 name='JitsiMeetView'418 component={JitsiMeetView}419 options={{ headerShown: false }}420 />421 </InsideStack.Navigator>422 );423};...
main-stack.js
Source:main-stack.js
...36import EditAccount from 'src/screens/profile/edit-account';37import Downloads from 'src/screens/profile/downloads';38import Page from 'src/screens/profile/Page';39const Stack = createStackNavigator();40function MainStack() {41 return (42 <Stack.Navigator43 initialRouteName={mainStack.home_tab}44 screenOptions={{gestureEnabled: false}}>45 <Stack.Screen46 options={{headerShown: false}}47 name={mainStack.home_tab}48 component={HomeTabs}49 />50 <Stack.Screen51 options={{headerShown: false}}52 name={mainStack.blogs}53 component={Blogs}54 />...
ErrorStack.js
Source:ErrorStack.js
1// |reftest| skip-if(!xulRuntime.shell) -- needs drainJobQueue2var BUGNUMBER = 1343158;3var summary = "Error.stack should provide meaningful stack trace in async function";4print(BUGNUMBER + ": " + summary);5let COOKIE = "C0F5DBB89807";6async function thrower() {7 let stack = new Error().stack; // line 118 assertEq(/^thrower@.+ErrorStack.js:11/m.test(stack), true, toMessage(stack));9 assertEq(/^inner@.+ErrorStack.js:38/m.test(stack), true, toMessage(stack));10 assertEq(/^async\*middle@.+ErrorStack.js:58/m.test(stack), true, toMessage(stack));11 assertEq(/^async\*outer@.+ErrorStack.js:78/m.test(stack), true, toMessage(stack));12 assertEq(/^async\*@.+ErrorStack.js:82/m.test(stack), true, toMessage(stack));13 throw new Error(COOKIE); // line 1814}15async function inner() {16 let stack = new Error().stack; // line 2217 assertEq(/thrower@.+ErrorStack.js/m.test(stack), false, toMessage(stack));18 assertEq(/^inner@.+ErrorStack.js:22/m.test(stack), true, toMessage(stack));19 assertEq(/^middle@.+ErrorStack.js:58/m.test(stack), true, toMessage(stack));20 assertEq(/^async\*outer@.+ErrorStack.js:78/m.test(stack), true, toMessage(stack));21 assertEq(/^async\*@.+ErrorStack.js:82/m.test(stack), true, toMessage(stack));22 await Promise.resolve(100);23 stack = new Error().stack; // line 3124 assertEq(/thrower@.+ErrorStack.js/m.test(stack), false, toMessage(stack));25 assertEq(/^inner@.+ErrorStack.js:31/m.test(stack), true, toMessage(stack));26 assertEq(/^async\*middle@.+ErrorStack.js:58/m.test(stack), true, toMessage(stack));27 assertEq(/^async\*outer@.+ErrorStack.js:78/m.test(stack), true, toMessage(stack));28 assertEq(/^async\*@.+ErrorStack.js:82/m.test(stack), true, toMessage(stack));29 await thrower(); // line 3830}31async function middle() {32 let stack = new Error().stack; // line 4233 assertEq(/thrower@.+ErrorStack.js/m.test(stack), false, toMessage(stack));34 assertEq(/inner@.+ErrorStack.js/m.test(stack), false, toMessage(stack));35 assertEq(/^middle@.+ErrorStack.js:42/m.test(stack), true, toMessage(stack));36 assertEq(/^outer@.+ErrorStack.js:78/m.test(stack), true, toMessage(stack));37 assertEq(/^async\*@.+ErrorStack.js:82/m.test(stack), true, toMessage(stack));38 await Promise.resolve(1000);39 stack = new Error().stack; // line 5140 assertEq(/thrower@.+ErrorStack.js/m.test(stack), false, toMessage(stack));41 assertEq(/inner@.+ErrorStack.js/m.test(stack), false, toMessage(stack));42 assertEq(/^middle@.+ErrorStack.js:51/m.test(stack), true, toMessage(stack));43 assertEq(/^async\*outer@.+ErrorStack.js:78/m.test(stack), true, toMessage(stack));44 assertEq(/^async\*@.+ErrorStack.js:82/m.test(stack), true, toMessage(stack));45 await inner(); // line 5846}47async function outer() {48 let stack = new Error().stack; // line 6249 assertEq(/thrower@.+ErrorStack.js/m.test(stack), false, toMessage(stack));50 assertEq(/inner@.+ErrorStack.js/m.test(stack), false, toMessage(stack));51 assertEq(/middle@.+ErrorStack.js/m.test(stack), false, toMessage(stack));52 assertEq(/^outer@.+ErrorStack.js:62/m.test(stack), true, toMessage(stack));53 assertEq(/^@.+ErrorStack.js:82/m.test(stack), true, toMessage(stack));54 await Promise.resolve(10000);55 stack = new Error().stack; // line 7156 assertEq(/thrower@.+ErrorStack.js/m.test(stack), false, toMessage(stack));57 assertEq(/inner@.+ErrorStack.js/m.test(stack), false, toMessage(stack));58 assertEq(/middle@.+ErrorStack.js/m.test(stack), false, toMessage(stack));59 assertEq(/^outer@.+ErrorStack.js:71/m.test(stack), true, toMessage(stack));60 assertEq(/^async\*@.+ErrorStack.js:82/m.test(stack), true, toMessage(stack));61 await middle(); // line 7862}63try {64 getPromiseResult(outer()); // line 8265 assertEq(true, false);66} catch (e) {67 // Re-throw the exception to log the assertion failure properly.68 if (!e.message.includes(COOKIE))69 throw e;70 let stack = e.stack;71 assertEq(/^thrower@.+ErrorStack.js:18/m.test(stack), true, toMessage(stack));72 assertEq(/^inner@.+ErrorStack.js:38/m.test(stack), true, toMessage(stack));73 assertEq(/^async\*middle@.+ErrorStack.js:58/m.test(stack), true, toMessage(stack));74 assertEq(/^async\*outer@.+ErrorStack.js:78/m.test(stack), true, toMessage(stack));75 assertEq(/^async\*@.+ErrorStack.js:82/m.test(stack), true, toMessage(stack));76}77function toMessage(stack) {78 // Provide the stack string in the error message for debugging.79 return `[stack: ${stack.replace(/\n/g, "\\n")}]`;80}81if (typeof reportCompare === "function")...
History.js
Source:History.js
1import range from '../core/range';2export default class History {3 constructor($editable) {4 this.stack = [];5 this.stackOffset = -1;6 this.$editable = $editable;7 this.editable = $editable[0];8 }9 makeSnapshot() {10 const rng = range.create(this.editable);11 const emptyBookmark = { s: { path: [], offset: 0 }, e: { path: [], offset: 0 } };12 return {13 contents: this.$editable.html(),14 bookmark: ((rng && rng.isOnEditable()) ? rng.bookmark(this.editable) : emptyBookmark),15 };16 }17 applySnapshot(snapshot) {18 if (snapshot.contents !== null) {19 this.$editable.html(snapshot.contents);20 }21 if (snapshot.bookmark !== null) {22 range.createFromBookmark(this.editable, snapshot.bookmark).select();23 }24 }25 /**26 * @method rewind27 * Rewinds the history stack back to the first snapshot taken.28 * Leaves the stack intact, so that "Redo" can still be used.29 */30 rewind() {31 // Create snap shot if not yet recorded32 if (this.$editable.html() !== this.stack[this.stackOffset].contents) {33 this.recordUndo();34 }35 // Return to the first available snapshot.36 this.stackOffset = 0;37 // Apply that snapshot.38 this.applySnapshot(this.stack[this.stackOffset]);39 }40 /**41 * @method commit42 * Resets history stack, but keeps current editor's content.43 */44 commit() {45 // Clear the stack.46 this.stack = [];47 // Restore stackOffset to its original value.48 this.stackOffset = -1;49 // Record our first snapshot (of nothing).50 this.recordUndo();51 }52 /**53 * @method reset54 * Resets the history stack completely; reverting to an empty editor.55 */56 reset() {57 // Clear the stack.58 this.stack = [];59 // Restore stackOffset to its original value.60 this.stackOffset = -1;61 // Clear the editable area.62 this.$editable.html('');63 // Record our first snapshot (of nothing).64 this.recordUndo();65 }66 /**67 * undo68 */69 undo() {70 // Create snap shot if not yet recorded71 if (this.$editable.html() !== this.stack[this.stackOffset].contents) {72 this.recordUndo();73 }74 if (this.stackOffset > 0) {75 this.stackOffset--;76 this.applySnapshot(this.stack[this.stackOffset]);77 }78 }79 /**80 * redo81 */82 redo() {83 if (this.stack.length - 1 > this.stackOffset) {84 this.stackOffset++;85 this.applySnapshot(this.stack[this.stackOffset]);86 }87 }88 /**89 * recorded undo90 */91 recordUndo() {92 this.stackOffset++;93 // Wash out stack after stackOffset94 if (this.stack.length > this.stackOffset) {95 this.stack = this.stack.slice(0, this.stackOffset);96 }97 // Create new snapshot and push it to the end98 this.stack.push(this.makeSnapshot());99 }...
stack.two.spec.js
Source:stack.two.spec.js
1var stack = require("../../lib/dataStructures/stack.js");2describe('When pushing two elements to a stack', function () {3 var myStack;4 var testValue1 = "test_string1"5 var testValue2 = "test_string2"6 beforeEach(function() {7 myStack = new stack();8 myStack.push(testValue1);9 myStack.push(testValue2);10 });11 afterEach(function() {12 myStack = null;13 });14 it('the stack`s length should be 2', function () {15 expect(myStack.length).toBe(2);16 });17});18describe('When pushing two elements to a stack and then popping an element', function () {19 var myStack;20 var testValue1 = "test_string1"21 var testValue2 = "test_string2"22 beforeEach(function() {23 myStack = new stack();24 myStack.push(testValue1);25 myStack.push(testValue2);26 });27 afterEach(function() {28 myStack = null;29 });30 it('the stack`s length should be 1', function () {31 var result = myStack.pop();32 expect(myStack.length).toBe(1);33 });34 it('the element popped should be the last element added.', function () {35 var result = myStack.pop();36 expect(result).toBe(testValue2);37 });38});39describe('When pushing two elements to a stack and then popping 2 elements', function () {40 var myStack;41 var testValue1 = "test_string1"42 var testValue2 = "test_string2"43 beforeEach(function() {44 myStack = new stack();45 myStack.push(testValue1);46 myStack.push(testValue2);47 });48 afterEach(function() {49 myStack = null;50 });51 it('the stack`s length should be 0', function () {52 myStack.pop();53 myStack.pop();54 expect(myStack.length).toBe(0);55 });56 it('the elements popped should be in the inverse order to which they were added.', function () {57 var result1 = myStack.pop();58 var result2 = myStack.pop();59 expect(result1).toBe(testValue2);60 expect(result2).toBe(testValue1);61 });...
Using AI Code Generation
1var ladle = require('./ladle.js');2var stack = new ladle.Stack();3stack.push(1);4stack.push(2);5stack.push(3);6stack.push(4);7stack.push(5);8stack.push(6);9stack.push(7);10stack.push(8);11stack.push(9);12stack.push(10);13stack.push(11);14stack.push(12);15stack.push(13);16stack.push(14);17stack.push(15);18stack.push(16);19stack.push(17);20stack.push(18);21stack.push(19);22stack.push(20);23stack.push(21);24stack.push(22);25stack.push(23);26stack.push(24);27stack.push(25);28stack.push(26);29stack.push(27);30stack.push(28);31stack.push(29);32stack.push(30);33stack.push(31);34stack.push(32);35stack.push(33);36stack.push(34);37stack.push(35);38stack.push(36);39stack.push(37);40stack.push(38);41stack.push(39);42stack.push(40);43stack.push(41);44stack.push(42);45stack.push(43);46stack.push(44);47stack.push(45);48stack.push(46);49stack.push(47);50stack.push(48);51stack.push(49);52stack.push(50);53stack.push(51);54stack.push(52);55stack.push(53);56stack.push(54);57stack.push(55);58stack.push(56);59stack.push(57);60stack.push(58);61stack.push(59);62stack.push(60);63stack.push(61);64stack.push(62);65stack.push(63);66stack.push(64);67stack.push(65);68stack.push(66);69stack.push(67);70stack.push(68);71stack.push(69);72stack.push(70);73stack.push(71);74stack.push(72);75stack.push(73);76stack.push(74);77stack.push(75);78stack.push(76);79stack.push(77);80stack.push(78);81stack.push(79);82stack.push(80);83stack.push(81);84stack.push(82);85stack.push(83);86stack.push(84);87stack.push(85);88stack.push(86);89stack.push(87);90stack.push(88);91stack.push(89);92stack.push(90);93stack.push(91);94stack.push(92);95stack.push(93);96stack.push(94);97stack.push(95);98stack.push(96
Using AI Code Generation
1var ladle = require('ladle');2var stack = new ladle.Stack();3stack.push(1);4stack.push(2);5stack.push(3);6var ladle = require('ladle');7var queue = new ladle.Queue();8queue.enqueue(1);9queue.enqueue(2);10queue.enqueue(3);11var ladle = require('ladle');12var list = new ladle.LinkedList();13list.insert(1);14list.insert(2);15list.insert(3);16var ladle = require('ladle');17var bst = new ladle.BinarySearchTree();18bst.insert(1);19bst.insert(2);20bst.insert(3);21var ladle = require('ladle');22var heap = new ladle.Heap();23heap.insert(1);24heap.insert(2);25heap.insert(3);26var ladle = require('ladle');27var graph = new ladle.Graph();28graph.addNode(1);29graph.addNode(2);30graph.addNode(3);31graph.addEdge(1, 2, 3);32graph.addEdge(2, 3, 4);33graph.addEdge(3, 1, 5);34graph.removeEdge(1, 2);35graph.removeEdge(2, 3);36graph.removeEdge(3, 1);37graph.removeNode(1);38graph.removeNode(2);39graph.removeNode(3);40var ladle = require('ladle');41var set = new ladle.Set();42set.add(1
Using AI Code Generation
1var ladle = require('./ladle');2var stack = ladle.Stack();3stack.push(10);4stack.push(20);5stack.push(30);6stack.push(40);7stack.push(50);8stack.push(60);9stack.push(70);10stack.push(80);11stack.push(90);12stack.push(100);13stack.push(110);14stack.push(120);15stack.push(130);16stack.push(140);17stack.push(150);18stack.push(160);19stack.push(170);20stack.push(180);21stack.push(190);22stack.push(200);23stack.push(210);24stack.push(220);25stack.push(230);26stack.push(240);27stack.push(250);28stack.push(260);29stack.push(270);30stack.push(280);31stack.push(290);32stack.push(300);33stack.push(310);34stack.push(320);35stack.push(330);36stack.push(340);37stack.push(350);38stack.push(360);39stack.push(370);40stack.push(380);41stack.push(390);42stack.push(400);43stack.push(410);44stack.push(420);45stack.push(430);46stack.push(440);47stack.push(450);48stack.push(460);49stack.push(470);50stack.push(480);51stack.push(490);52stack.push(500);53stack.push(510);54stack.push(520);55stack.push(530);56stack.push(540);57stack.push(550);58stack.push(560);59stack.push(570);60stack.push(580);61stack.push(590);62stack.push(600);63stack.push(610);64stack.push(620);65stack.push(630);66stack.push(640);67stack.push(650);68stack.push(660);69stack.push(670);70stack.push(680);71stack.push(690);72stack.push(700);73stack.push(710);74stack.push(720);75stack.push(730);76stack.push(740);77stack.push(750);78stack.push(760);79stack.push(770);80stack.push(780);81stack.push(790);82stack.push(800);83stack.push(810);84stack.push(820);85stack.push(830);86stack.push(840);87stack.push(850);88stack.push(860);89stack.push(870);90stack.push(880);91stack.push(890);92stack.push(900);93stack.push(910);94stack.push(920);95stack.push(930);96stack.push(940);97stack.push(950);98stack.push(960);
Using AI Code Generation
1var ladle = require('./ladle.js');2var ladle_stack = ladle.Stack();3ladle_stack.push(10);4ladle_stack.push(20);5ladle_stack.push(30);6console.log(ladle_stack.pop());7console.log(ladle_stack.pop());8console.log(ladle_stack.pop());9console.log(ladle_stack.pop());10var ladle = require('./ladle.js');11var ladle_queue = ladle.Queue();12ladle_queue.enqueue(10);13ladle_queue.enqueue(20);14ladle_queue.enqueue(30);15console.log(ladle_queue.dequeue());16console.log(ladle_queue.dequeue());17console.log(ladle_queue.dequeue());18console.log(ladle_queue.dequeue());19var ladle = require('./ladle.js');20var ladle_set = ladle.Set();21ladle_set.add(10);22ladle_set.add(20);23ladle_set.add(30);24console.log(ladle_set.remove(20));25console.log(ladle_set.remove(20));26console.log(ladle_set.remove(30));27console.log(ladle_set.remove(30));28console.log(ladle_set.remove(10));29console.log(ladle_set.remove(10));30var ladle = require('./ladle.js');31var ladle_linkedlist = ladle.LinkedList();32ladle_linkedlist.add(10);33ladle_linkedlist.add(20);34ladle_linkedlist.add(30);35console.log(ladle_linkedlist.remove(20));36console.log(ladle_linkedlist.remove(20));37console.log(ladle_linkedlist.remove(30));38console.log(ladle_linkedlist.remove(30));39console.log(ladle_linkedlist.remove(10));40console.log(ladle_linkedlist.remove(10));41var ladle = require('./ladle.js');42var ladle_binarysearchtree = ladle.BinarySearchTree();43ladle_binarysearchtree.add(10);44ladle_binarysearchtree.add(20);45ladle_binarysearchtree.add(30);46console.log(ladle_binarysearchtree.remove(20));47console.log(ladle_binarysearchtree.remove(20));48console.log(ladle_binarysearchtree.remove(30));49console.log(ladle_binarysearchtree.remove(30));
Using AI Code Generation
1var ladle = require('ladle');2var ladleStack = ladle.stack();3ladleStack.start(function(err, stack) {4 if (err) {5 console.log('Could not start stack', err);6 } else {7 console.log('Started stack', stack);8 }9});10var ladle = require('ladle');11var ladleStack = ladle.stack();12ladleStack.start(function(err, stack) {13 if (err) {14 console.log('Could not start stack', err);15 } else {16 console.log('Started stack', stack);17 }18});19var ladle = require('ladle');20var ladleStack = ladle.stack();21ladleStack.start(function(err, stack) {22 if (err) {23 console.log('Could not start stack', err);24 } else {25 console.log('Started stack', stack);26 }27});28var ladle = require('ladle');29var ladleStack = ladle.stack();30ladleStack.start(function(err, stack) {31 if (err) {32 console.log('Could not start stack', err);33 } else {34 console.log('Started stack', stack);35 }36});37var ladle = require('ladle');38var ladleStack = ladle.stack();39ladleStack.start(function(err, stack) {40 if (err) {41 console.log('Could not start stack', err);42 } else {43 console.log('Started stack', stack);44 }45});46var ladle = require('ladle');47var ladleStack = ladle.stack();48ladleStack.start(function(err, stack) {49 if (err) {50 console.log('Could not start stack', err);51 } else {52 console.log('Started stack', stack);53 }54});55var ladle = require('ladle');56var ladleStack = ladle.stack();57ladleStack.start(function(err, stack) {58 if (err) {59 console.log('Could not start stack', err);60 } else {61 console.log('Started stack', stack);62 }63});
Using AI Code Generation
1var ladle = require('ladle');2var stack = ladle.stack();3stack.create(function(err, id) {4 if (err) {5 console.log(err);6 } else {7 console.log('stack created: ' + id);8 }9});10stack.remove('stack_id', function(err) {11 if (err) {12 console.log(err);13 } else {14 console.log('stack removed');15 }16});17stack.list(function(err, stacks) {18 if (err) {19 console.log(err);20 } else {21 console.log('stacks: ' + stacks);22 }23});24stack.get('stack_id', function(err, stack) {25 if (err) {26 console.log(err);27 } else {28 console.log('stack: ' + stack);29 }30});31stack.update('stack_id', 'name', 'value', function(err, stack) {32 if (err) {33 console.log(err);34 } else {35 console.log('stack updated: ' + stack);36 }37});38stack.getTemplate('stack_id', function(err, template) {39 if (err) {40 console.log(err);41 } else {42 console.log('stack template: ' + template);43 }44});45stack.getFiles('stack_id', function(err, files) {46 if (err) {47 console.log(err);48 } else {49 console.log('stack files: ' + files);50 }51});52stack.getFile('stack_id', 'file_id', function(err, file) {53 if (err) {54 console.log(err);55 } else {56 console.log('stack file: ' + file);57 }58});59stack.getFileContent('stack_id', 'file_id', function(err, content) {60 if (err) {61 console.log(err);62 } else {63 console.log('stack file content: ' + content);64 }65});66stack.getFileContent('stack_id', 'file_id', function(err, content) {67 if (err) {68 console.log(err);69 } else {70 console.log('stack file content: ' + content);71 }72});
Using AI Code Generation
1var ladle = require('ladle');2var stack = ladle.stack();3stack.create('test', function(err, container) {4});5stack.start('test', function(err, container) {6});7stack.stop('test', function(err, container) {8});9stack.destroy('test', function(err, container) {10});11var ladle = require('ladle');12var pool = ladle.pool();13pool.create('test', function(err, container) {14});15pool.start('test', function(err, container) {16});17pool.stop('test', function(err, container) {18});19pool.destroy('test', function(err, container) {20});21var ladle = require('ladle');22var pool = ladle.pool({23 portBindings: {24 '3000/tcp': [{HostPort: '3000'}]25 },26 env: {27 },28});29pool.create('test', function(err, container) {30});31pool.start('test', function(err, container) {32});33pool.stop('test', function(err, container) {34});35pool.destroy('test', function(err, container) {36});37#### ladle.stack(options)
Using AI Code Generation
1var ladle = require('./ladle.js');2var ladleObj = ladle();3var stack = ladleObj.stack();4stack.push("hello");5stack.push("world");6stack.push("!");7stack.pop();8stack.pop();9stack.pop();10stack.pop();11stack.pop();12stack.pop();13stack.pop();14var ladleObj = ladle();15var queue = ladleObj.queue();16queue.enqueue("hello");17queue.enqueue("world");18queue.enqueue("!");19queue.dequeue();20queue.dequeue();21queue.dequeue();22queue.dequeue();23queue.dequeue();24queue.dequeue();25queue.dequeue();26var ladleObj = ladle();27var set = ladleObj.set();28set.add("hello");29set.add("world");30set.add("!");31set.remove("hello");32set.remove("world");33set.remove("!");34set.remove("hello");35set.remove("world");36set.remove("!");37set.remove("hello");38set.remove("world");39set.remove("!");40var ladleObj = ladle();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!