Best JavaScript code snippet using wpt
body.js
Source:body.js
1import {tiny} from './common.js';2// Pull these names into this module's scope for convenience:3const {vec3, vec4, Mat4} = tiny;4const BALL_COLLISION_ITER = 25export class Body {6 // **Body** can store and update the properties of a 3D body that incrementally7 // moves from its previous place due to velocities. It conforms to the8 // approach outlined in the "Fix Your Timestep!" blog post by Glenn Fiedler.9 constructor(shape, material, size, weight=0, rolling_friction=0, type='') {10 Object.assign(this,11 {shape, material, size, weight, rolling_friction, type})12 this.center = vec3(0, 0, 0);13 this.rotation = Mat4.identity();14 this.linear_velocity = vec3(0, 0, 0);15 this.previous = {center: this.center.copy(), rotation: this.rotation.copy(), linear_velocity: this.linear_velocity.copy()};16 // drawn_location gets replaced with an interpolated quantity:17 this.drawn_location = Mat4.identity();18 this.temp_matrix = Mat4.identity();19 Object.assign(this, {angular_velocity: 0, spin_axis: vec3(1, 0, 0)})20 }21 // (within some margin of distance).22 static intersect_cube(p, margin = 0) {23 return p.every(value => value >= -1 - margin && value <= 1 + margin)24 }25 static intersect_sphere(p, margin = 0) {26 return p.dot(p) < 1 + margin;27 }28 // emplace(): assign the body's initial values, or overwrite them.29 emplace(location_matrix, linear_velocity, angular_velocity, spin_axis = vec3(0, 0, 0).randomized(1).normalized()) {30 this.center = location_matrix.times(vec4(0, 0, 0, 1)).to3();31 this.rotation = Mat4.translation(...this.center.times(-1)).times(location_matrix);32 this.previous = {center: this.center.copy(), rotation: this.rotation.copy()};33 // drawn_location gets replaced with an interpolated quantity:34 this.drawn_location = location_matrix;35 this.temp_matrix = Mat4.identity();36 return Object.assign(this, {linear_velocity, angular_velocity, spin_axis})37 }38 compute_state_at(time_amount) {39 let position = this.center, velocity = this.linear_velocity40 // Linear velocity first41 if (this.linear_velocity.norm() > 1e-10) {42 if (this.rolling_friction * time_amount >= this.linear_velocity.norm()) {43 let stop_time = this.linear_velocity.norm() / this.rolling_friction;44 //center: p = p0 + v0*t + 0.5*at^245 position = this.center.plus(this.linear_velocity.times(stop_time))46 .plus(this.linear_velocity.normalized().times(-this.rolling_friction * stop_time * stop_time));47 // velocity: v = v0 + at48 velocity = vec3(0, 0, 0)49 return {position, velocity, stop_time}50 } else {51 //center: p = p0 + v0*t + 0.5*at^252 position = this.center.plus(this.linear_velocity.times(time_amount))53 .plus(this.linear_velocity.normalized().times(-this.rolling_friction * time_amount * time_amount));54 velocity = this.linear_velocity.minus(this.linear_velocity.normalized().times(this.rolling_friction * time_amount))55 }56 }57 return {position, velocity, stop_time: null}58 }59 set_previous() {60 this.previous = {center: this.center.copy(), rotation: this.rotation.copy(), linear_velocity: this.linear_velocity.copy()};61 }62 advance(time_amount, set_previous = true) {63 // advance(): Perform an integration (the simplistic Forward Euler method) to64 // advance all the linear and angular velocities one time-step forward.65 if (set_previous) this.set_previous()66 // Apply the velocities scaled proportionally to real time (time_amount):67 // Linear velocity first68 let new_state = this.compute_state_at(time_amount)69 this.center = new_state.position70 this.linear_velocity = new_state.velocity71 //angular velocity72 this.rotation.pre_multiply(Mat4.rotation(time_amount * this.angular_velocity, ...this.spin_axis));73 }74 // The following are our various functions for testing a single point,75 // p, against some analytically-known geometric volume formula76 blend_rotation(alpha) {77 // blend_rotation(): Just naively do a linear blend of the rotations, which looks78 // ok sometimes but otherwise produces shear matrices, a wrong result.79 // TODO: Replace this function with proper quaternion blending, and perhaps80 // store this.rotation in quaternion form instead for compactness.81 return this.rotation.map((x, i) => vec4(...this.previous.rotation[i]).mix(x, alpha));82 }83 blend_state(alpha) {84 // blend_state(): Compute the final matrix we'll draw using the previous two physical85 // locations the object occupied. We'll interpolate between these two states as86 // described at the end of the "Fix Your Timestep!" blog post.87 this.drawn_location = Mat4.translation(...this.previous.center.mix(this.center, alpha))88 .times(this.blend_rotation(alpha))89 .times(Mat4.scale(...this.size));90 }91 check_if_colliding(b, collider) {92 // check_if_colliding(): Collision detection function.93 // DISCLAIMER: The collision method shown below is not used by anyone; it's just very quick94 // to code. Making every collision body an ellipsoid is kind of a hack, and looping95 // through a list of discrete sphere points to see if the ellipsoids intersect is *really* a96 // hack (there are perfectly good analytic expressions that can test if two ellipsoids97 // intersect without discretizing them into points).98 if (this == b)99 return false;100 // Nothing collides with itself.101 // Convert sphere b to the frame where a is a unit sphere:102 const T = this.inverse.times(b.drawn_location, this.temp_matrix);103 const {intersect_test, points, leeway} = collider;104 // For each vertex in that b, shift to the coordinate frame of105 // a_inv*b. Check if in that coordinate frame it penetrates106 // the unit sphere at the origin. Leave some leeway.107 return points.arrays.position.some(p =>108 intersect_test(T.times(p.to4(1)).to3(), leeway));109 }110 /**111 * the boundary checking algorithm for sphere112 * @param boundary the array of vec3 representing the boundary polygon113 * @param dt the time to check114 */115 check_if_colliding_boundary(boundary, dt) {116 let this_r = Math.max(this.size[0], this.size[1], this.size[2])117 let boundary_normal = boundary[1].minus(boundary[0]).cross(boundary[2].minus(boundary[1])).normalized()118 if (this.center.minus(boundary[0]).dot(boundary_normal) < 0) boundary_normal = boundary_normal.times(-1); // face this object119 let moved_polygon = boundary.map((e) => e.plus(boundary_normal.times(this_r)));120 let no_collision_end_state = this.compute_state_at(dt)121 if (no_collision_end_state.position.minus(moved_polygon[0]).dot(boundary_normal) > 0) return false; //did not cross boundary's plane122 //intersection point123 let begin_height = this.center.minus(moved_polygon[0]).dot(boundary_normal)124 let end_height = - no_collision_end_state.position.minus(moved_polygon[0]).dot(boundary_normal)125 let intersection_point = this.center.times(begin_height / (begin_height + end_height)).plus(no_collision_end_state.position.times(end_height / (begin_height + end_height)))126 //in polygon check127 let sign = moved_polygon[0].minus(moved_polygon[moved_polygon.length - 1]).cross(intersection_point.minus(moved_polygon[moved_polygon.length - 1])).dot(boundary_normal)128 for (let i = 0; i < moved_polygon.length - 1; i ++) {129 let second_sign = moved_polygon[i + 1].minus(moved_polygon[i]).cross(intersection_point.minus(moved_polygon[i])).dot(boundary_normal)130 if (second_sign * sign <= 0) return false;131 }132 return true;133 }134 /**135 * the boundary collision algorithm for sphere136 * @param boundary the array of vec3 representing the boundary polygon137 * @param dt the time to run138 */139 boundary_collision(boundary, dt) {140 let this_r = Math.max(this.size[0], this.size[1], this.size[2])141 let boundary_normal = boundary[1].minus(boundary[0]).cross(boundary[2].minus(boundary[1])).normalized()142 if (this.center.minus(boundary[0]).dot(boundary_normal) < 0) boundary_normal = boundary_normal.times(-1); // face this object143 let moved_polygon = boundary.map((e) => e.plus(boundary_normal.times(this_r)));144 let no_collision_end_state = this.compute_state_at(dt)145 if (this.linear_velocity.dot(boundary_normal) > 0) return {...no_collision_end_state, dt}; //going out of the plane, no collision146 if (no_collision_end_state.position.minus(moved_polygon[0]).dot(boundary_normal) > 0) return {...no_collision_end_state, dt}; //did not cross boundary's plane147 //intersection point148 let begin_height = this.center.minus(moved_polygon[0]).dot(boundary_normal)149 let end_height = - no_collision_end_state.position.minus(moved_polygon[0]).dot(boundary_normal)150 let intersection_point = this.center.times(end_height / (begin_height + end_height)).plus(no_collision_end_state.position.times(begin_height / (begin_height + end_height)))151 //in polygon check152 let sign = moved_polygon[0].minus(moved_polygon[moved_polygon.length - 1]).cross(intersection_point.minus(moved_polygon[moved_polygon.length - 1])).dot(boundary_normal)153 for (let i = 0; i < moved_polygon.length - 1; i ++) {154 let second_sign = moved_polygon[i + 1].minus(moved_polygon[i]).cross(intersection_point.minus(moved_polygon[i])).dot(boundary_normal)155 if (second_sign * sign <= 0) return {...no_collision_end_state, dt};156 }157 let intersection_speed = Math.sqrt(this.linear_velocity.dot(this.linear_velocity) - 2 * this.rolling_friction * (intersection_point.minus(this.center).norm()))158 let velocity_direction = this.linear_velocity.normalized()159 velocity_direction = velocity_direction.minus(boundary_normal.times(2 * velocity_direction.dot(boundary_normal)))160 let result_velocity = velocity_direction.times(intersection_speed)161 let intersection_dt = (intersection_point.minus(this.center).norm()) / (this.linear_velocity.norm() + intersection_speed) * 2162 return {position: intersection_point, velocity: result_velocity, stop_time: null, dt: intersection_dt}163 }164 /**165 * the boundary edge collision algorithm for sphere166 * @param edge the array of vec3 representing the boundary polygon167 * @param dt the time to run168 */169 edge_collision(edge, dt) {170 let this_r = Math.max(this.size[0], this.size[1], this.size[2])171 let no_collision_end_state = {...this.compute_state_at(dt), dt}172 //preliminary check - filter far ones173 let edge_direction = edge[1].minus(edge[0]).normalized()174 const edge0_to_ball = this.center.minus(edge[0])175 const ball_to_edge_on_plane = edge0_to_ball.minus(edge_direction.times(edge0_to_ball.dot(edge_direction)))176 if (ball_to_edge_on_plane.norm() > this.linear_velocity.norm() * dt + this_r) return no_collision_end_state // *2 for safety177 const edge_to_velocity = edge_direction.cross(this.linear_velocity).normalized()178 const closest_distance = edge0_to_ball.dot(edge_to_velocity)179 if (Math.abs(closest_distance) > this_r) return no_collision_end_state180 const edge_collision_point = edge[0].plus(edge_direction.times(this.center.minus(edge[0]).dot(edge_direction)))181 const unit_velocity = this.linear_velocity.normalized()182 const closest_position = this.center.plus(unit_velocity.times(edge[0].minus(this.center).dot(unit_velocity)))183 const collision_ball_center_to_closest_point_len = Math.sqrt(this_r * this_r - closest_distance * closest_distance)184 const collision_ball_center = closest_position.minus(unit_velocity.times(collision_ball_center_to_closest_point_len))185 if (no_collision_end_state.position.minus(collision_ball_center).dot(collision_ball_center.minus(this.center)) > 0) { //closest position between the trajectory186 return no_collision_end_state187 }188 //construct a surface then return the collision result189 const surface_normal = collision_ball_center.minus(edge_collision_point)190 const second_plane_direction = edge_direction.cross(surface_normal).normalized()191 return this.boundary_collision([edge_collision_point.minus(edge_direction).minus(second_plane_direction),192 edge_collision_point.minus(edge_direction).plus(second_plane_direction),193 edge_collision_point.plus(edge_direction).plus(second_plane_direction),194 edge_collision_point.plus(edge_direction).minus(second_plane_direction)], dt)195 }196 static ball_collision_time_iter(ballA, ballB, dt, debug = false) {197 //solve collision time198 //norm( p + vt - p' - v't ) = r + r'199 let deltaP = ballA.position.minus(ballB.position)200 let deltaV = ballA.velocity.minus(ballB.velocity)201 let equation_a = deltaV.dot(deltaV)202 let equation_b = 2 * deltaP.dot(deltaV)203 let equation_c = deltaP.dot(deltaP) - (ballA.radius + ballB.radius) ** 2204 let equation_delta = equation_b ** 2 - 4 * equation_a * equation_c205 if (equation_delta <= 0) return null;206 let t_1 = (- equation_b - Math.sqrt(equation_delta)) / (2 * equation_a)207 let t_2 = (- equation_b + Math.sqrt(equation_delta)) / (2 * equation_a)208 if (debug) console.log(t_1, t_2)209 if (t_1 < 0 || t_2 < 0 || t_1 > dt) return null;210 return t_1;211 }212 /**213 * https://stackoverflow.com/questions/35211114/2d-elastic-ball-collision-physics214 * @param otherBall:Body215 * @param dt216 */217 ball_collision(otherBall, dt) {218 let no_collision_end_state = {...this.compute_state_at(dt), dt}219 if (this === otherBall) return no_collision_end_state220 let this_r = Math.max(this.size[0], this.size[1], this.size[2])221 let otherBall_r = Math.max(otherBall.size[0], otherBall.size[1], otherBall.size[2])222 //preliminary check223 if (this.center.minus(otherBall.center).norm() >224 this_r + otherBall_r + this.linear_velocity.norm() * dt + otherBall.linear_velocity.norm() * dt)225 return no_collision_end_state;226 //solve collision time227 //norm( p + vt - p' - v't ) = r + r'228 let t = 0;229 let this_ball_state = {position: this.center, velocity: this.linear_velocity, radius: this_r}230 let other_ball_state = {position: otherBall.center, velocity: otherBall.linear_velocity, radius: otherBall_r}231 for (let i = 0; i < BALL_COLLISION_ITER; i ++) {232 const next_point_t = Body.ball_collision_time_iter(this_ball_state, other_ball_state, dt);233 if (t === 0 && next_point_t === null) return no_collision_end_state; // will this cause bug?234 if (next_point_t < 1E-5) break;235 t += next_point_t236 if (t > dt) return no_collision_end_state;237 let this_ball_next_state = this.compute_state_at(t)238 let other_ball_next_state = otherBall.compute_state_at(t)239 while (this_ball_next_state.position.minus(other_ball_next_state.position).norm() < (this_r + otherBall_r)) {240 t -= 1E-5241 this_ball_next_state = this.compute_state_at(t)242 other_ball_next_state = otherBall.compute_state_at(t)243 }244 this_ball_state.position = this_ball_next_state.position245 this_ball_state.velocity = this_ball_next_state.velocity246 other_ball_state.position = other_ball_next_state.position247 other_ball_state.velocity = other_ball_next_state.velocity248 if ((this_ball_next_state.stop_time !== null && this_ball_next_state.stop_time < t) ||249 (other_ball_next_state.stop_time !== null && other_ball_next_state.stop_time < t)) {250 return no_collision_end_state251 }252 }253 //forward to collision254 let deltaP = this_ball_state.position.minus(other_ball_state.position)255 let deltaV = this_ball_state.velocity.minus(other_ball_state.velocity)256 const this_ball_result_velocity = this_ball_state.velocity.minus(deltaP.times(deltaV.dot(deltaP) / deltaP.dot(deltaP)))257 deltaP = other_ball_state.position.minus(this_ball_state.position)258 deltaV = other_ball_state.velocity.minus(this_ball_state.velocity)259 const other_ball_result_velocity = other_ball_state.velocity.minus(deltaP.times(deltaV.dot(deltaP) / deltaP.dot(deltaP)))260 return {dt: t, velocity: this_ball_result_velocity, position: this_ball_state.position, stop_time: null,261 other: {body: otherBall, dt: t, velocity: other_ball_result_velocity, position: other_ball_state.position, stop_time: null}}262 }263 pocket_update(pocket, r, ballCenterHeight) {264 const pocket_on_this_level = pocket;265 pocket_on_this_level[1] = this.center[1];266 const center_dist = pocket_on_this_level.minus(this.center)267 if (center_dist.norm() > r) return {captured: false, removable: false};268 let this_r = Math.max(this.size[0], this.size[1], this.size[2])269 if (this.center.minus(pocket_on_this_level).norm() <= (r - this_r)) return {captured: true, removable: true};270 this.linear_velocity = center_dist271 const off_edge = r - center_dist.norm();272 const height = Math.sqrt(this_r ** 2 - off_edge ** 2);273 const downward_dy = this_r - height;274 this.center.center = ballCenterHeight - downward_dy;275 return {captured: true, removable: false};276 }...
GraphSetting.js
Source:GraphSetting.js
1const nodeSizeChange = document.querySelector(".nodeSize");2nodeSizeChange.addEventListener("change", (e) => {3 e.stopPropagation();4 // change the global node size5 UI.nodeSize = parseInt(document.querySelector(".nodeSize").value);6 // change the label of the range input7 document.querySelector(".nodeSizeLabel").innerHTML = UI.nodeSize;8 UI.fire();9});10const weightedGraph = document.querySelector("#isWeighted[type=checkbox]");11weightedGraph.addEventListener('change', () => {12 UI.isWighted = !UI.isWighted;13})14const edge_direction = document.querySelector("#edge-direction[type=checkbox]");15edge_direction.addEventListener('change', () => {16 UI.isDirected = !UI.isDirected;17 console.log(UI.isDirected);18 UI.fire();...
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, resp) {4 if (err) {5 console.log(err);6 } else {7 console.log(resp.data['edge_direction']);8 }9});10var wptools = require('wptools');11var page = wptools.page('Albert Einstein');12page.get(function(err, resp) {13 if (err) {14 console.log(err);15 } else {16 console.log(resp.data['edge_direction']);17 }18});19var wptools = require('wptools');20var page = wptools.page('Albert Einstein');21page.get(function(err, resp) {22 if (err) {23 console.log(err);24 } else {25 console.log(resp.data['edge_direction']);26 }27});28var wptools = require('wptools');29var page = wptools.page('Albert Einstein');30page.get(function(err, resp) {31 if (err) {32 console.log(err);33 } else {34 console.log(resp.data['edge_direction']);35 }36});37var wptools = require('wptools');38var page = wptools.page('Albert Einstein');39page.get(function(err, resp) {40 if (err) {41 console.log(err);42 } else {43 console.log(resp.data['edge_direction']);44 }45});46var wptools = require('wptools');47var page = wptools.page('Albert Einstein');48page.get(function(err, resp) {49 if (err) {50 console.log(err);51 } else {52 console.log(resp.data['edge_direction']);53 }54});55var wptools = require('wptools');56var page = wptools.page('Albert Einstein');57page.get(function(err, resp) {58 if (err) {59 console.log(err);60 } else {
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Barack Obama');3page.get(function(err, resp) {4 console.log(resp.data.edge_direction);5});6var wptools = require('wptools');7var page = wptools.page('Barack Obama');8page.get(function(err, resp) {9 console.log(resp.data.edge_direction);10});11var wptools = require('wptools');12var page = wptools.page('Barack Obama');13page.get(function(err, resp) {14 console.log(resp.data.edge_direction);15});16var wptools = require('wptools');17var page = wptools.page('Barack Obama');18page.get(function(err, resp) {19 console.log(resp.data.edge_direction);20});21var wptools = require('wptools');22var page = wptools.page('Barack Obama');23page.get(function(err, resp) {24 console.log(resp.data.edge_direction);25});26var wptools = require('wptools');27var page = wptools.page('Barack Obama');28page.get(function(err, resp) {29 console.log(resp.data.edge_direction);30});31var wptools = require('wptools');32var page = wptools.page('Barack Obama');33page.get(function(err, resp) {34 console.log(resp.data.edge_direction);35});36var wptools = require('wptools');37var page = wptools.page('Barack Obama');38page.get(function(err, resp) {39 console.log(resp.data.edge_direction);40});41var wptools = require('wptools');42var page = wptools.page('Barack Obama');43page.get(function(err, resp) {
Using AI Code Generation
1var wptools = require("wptools");2var wp = new wptools.page("Barack Obama");3wp.edge_direction(function(err, data) {4 console.log(data);5});6var wptools = require("wptools");7var wp = new wptools.page("Barack Obama");8wp.edge_direction(function(err, data) {9 console.log(data);10});11var wptools = require("wptools");12var wp = new wptools.page("Barack Obama");13wp.edge_direction(function(err, data) {14 console.log(data);15});16var wptools = require("wptools");17var wp = new wptools.page("Barack Obama");18wp.edge_direction(function(err, data) {19 console.log(data);20});21var wptools = require("wptools");22var wp = new wptools.page("Barack Obama");23wp.edge_direction(function(err, data) {24 console.log(data);25});26var wptools = require("wptools");27var wp = new wptools.page("Barack Obama");28wp.edge_direction(function(err, data) {29 console.log(data);30});31var wptools = require("wptools");32var wp = new wptools.page("Barack Obama");33wp.edge_direction(function(err, data) {34 console.log(data);35});36var wptools = require("wptools");37var wp = new wptools.page("Barack Obama");38wp.edge_direction(function(err, data) {39 console.log(data);40});41var wptools = require("wptools");42var wp = new wptools.page("Barack Obama");43wp.edge_direction(function(err, data) {44 console.log(data);45});
Using AI Code Generation
1var wptools = require('wptools');2var wp = wptools.page('Barack Obama');3wp.edge_direction('birth_place', function(err, data) {4 console.log(data);5});6var wptools = require('wptools');7var wp = wptools.page('Barack Obama');8wp.edge_direction('birth_place', {format:'json'}, function(err, data) {9 console.log(data);10});11var wptools = require('wptools');12var wp = wptools.page('Barack Obama');13wp.edge_direction('birth_place', {format:'html'}, function(err, data) {14 console.log(data);15});16var wptools = require('wptools');17var wp = wptools.page('Barack Obama');18wp.edge_direction('birth_place', {format:'wiki'}, function(err, data) {19 console.log(data);20});21var wptools = require('wptools');22var wp = wptools.page('Barack Obama');23wp.edge_direction('birth_place', {format:'text'}, function(err, data) {24 console.log(data);25});26var wptools = require('wptools');27var wp = wptools.page('Barack Obama');28wp.edge_direction('birth_place', {format:'text', lang:'es'}, function(err, data) {29 console.log(data);30});31var wptools = require('wptools');32var wp = wptools.page('Barack Obama');33wp.edge_direction('birth_place', {format:'text', lang:'es', verbose:true}, function(err, data) {34 console.log(data);35});36var wptools = require('wptools');37var wp = wptools.page('Barack Obama');38wp.edge_direction('birth_place', {format:'text', lang
Using AI Code Generation
1var wptools = require('wptools');2var edge_direction = require('edge_direction');3var wp = wptools.page('Barack Obama', {format:'json'});4wp.get(function(err, info, meta) {5 console.log(info);6});7var wptools = require('wptools');8var edge_direction = require('edge_direction');9var wp = wptools.page('Barack Obama', {format:'json'});10wp.get(function(err, info, meta) {11 console.log(info);12});
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, resp) {4 console.log(resp.data.edge_direction);5});6{ [Error: Command failed: node test.js7 at ChildProcess.exithandler (child_process.js:751:12)8 at ChildProcess.EventEmitter.emit (events.js:98:17)9 at maybeClose (child_process.js:1015:16)10 at Process.ChildProcess._handle.onexit (child_process.js:1087:5)]11 cmd: 'node test.js' }
Using AI Code Generation
1var wptools = require('wptools');2wptools.edge_direction('Q42', 'P31', function(err, direction) {3 console.log(direction);4});5var wptools = require('wptools');6wptools.edge_direction('Q42', 'P31', function(err, direction) {7 console.log(direction);8});9var wptools = require('wptools');10wptools.edge_direction('Q42', 'P31', function(err, direction) {11 console.log(direction);12});13var wptools = require('wptools');14wptools.edge_direction('Q42', 'P31', function(err, direction) {15 console.log(direction);16});17var wptools = require('wptools');18wptools.edge_direction('Q42', 'P31', function(err, direction) {19 console.log(direction);20});21var wptools = require('wptools');22wptools.edge_direction('Q42', 'P31', function(err, direction) {23 console.log(direction);24});25var wptools = require('wptools');26wptools.edge_direction('Q42', 'P31', function(err, direction) {27 console.log(direction);28});29var wptools = require('
Using AI Code Generation
1const wptools = require('wptools');2const fs = require('fs');3const node = process.argv[2];4const output_file = process.argv[3];5const wp = new wptools();6wp.edge_direction(node)7 .then(result => {8 fs.writeFile(output_file, result, function(err) {9 if(err) { return console.log(err); }10 console.log("The file was saved!");11 });12 })13 .catch(err => {14 console.log(err);15 });
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!!