Best JavaScript code snippet using storybook-root
arc.js
Source:arc.js
1(function() {2 var arcToSegmentsCache = { },3 segmentToBezierCache = { },4 _join = Array.prototype.join,5 argsString;6 // Generous contribution by Raph Levien, from libsvg-0.1.0.tar.gz7 function arcToSegments(x, y, rx, ry, large, sweep, rotateX, ox, oy) {8 argsString = _join.call(arguments);9 if (arcToSegmentsCache[argsString]) {10 return arcToSegmentsCache[argsString];11 }12 var coords = getXYCoords(rotateX, rx, ry, ox, oy, x, y);13 var d = (coords.x1-coords.x0) * (coords.x1-coords.x0) +14 (coords.y1-coords.y0) * (coords.y1-coords.y0);15 var sfactor_sq = 1 / d - 0.25;16 if (sfactor_sq < 0) sfactor_sq = 0;17 var sfactor = Math.sqrt(sfactor_sq);18 if (sweep === large) sfactor = -sfactor;19 var xc = 0.5 * (coords.x0 + coords.x1) - sfactor * (coords.y1-coords.y0);20 var yc = 0.5 * (coords.y0 + coords.y1) + sfactor * (coords.x1-coords.x0);21 var th0 = Math.atan2(coords.y0-yc, coords.x0-xc);22 var th1 = Math.atan2(coords.y1-yc, coords.x1-xc);23 var th_arc = th1-th0;24 if (th_arc < 0 && sweep === 1) {25 th_arc += 2*Math.PI;26 }27 else if (th_arc > 0 && sweep === 0) {28 th_arc -= 2 * Math.PI;29 }30 var segments = Math.ceil(Math.abs(th_arc / (Math.PI * 0.5 + 0.001)));31 var result = [];32 for (var i=0; i<segments; i++) {33 var th2 = th0 + i * th_arc / segments;34 var th3 = th0 + (i+1) * th_arc / segments;35 result[i] = [xc, yc, th2, th3, rx, ry, coords.sin_th, coords.cos_th];36 }37 arcToSegmentsCache[argsString] = result;38 return result;39 }40 function getXYCoords(rotateX, rx, ry, ox, oy, x, y) {41 var th = rotateX * (Math.PI/180);42 var sin_th = Math.sin(th);43 var cos_th = Math.cos(th);44 rx = Math.abs(rx);45 ry = Math.abs(ry);46 var px = cos_th * (ox - x) * 0.5 + sin_th * (oy - y) * 0.5;47 var py = cos_th * (oy - y) * 0.5 - sin_th * (ox - x) * 0.5;48 var pl = (px*px) / (rx*rx) + (py*py) / (ry*ry);49 if (pl > 1) {50 pl = Math.sqrt(pl);51 rx *= pl;52 ry *= pl;53 }54 var a00 = cos_th / rx;55 var a01 = sin_th / rx;56 var a10 = (-sin_th) / ry;57 var a11 = (cos_th) / ry;58 return {59 x0: a00 * ox + a01 * oy,60 y0: a10 * ox + a11 * oy,61 x1: a00 * x + a01 * y,62 y1: a10 * x + a11 * y,63 sin_th: sin_th,64 cos_th: cos_th65 };66 }67 function segmentToBezier(cx, cy, th0, th1, rx, ry, sin_th, cos_th) {68 argsString = _join.call(arguments);69 if (segmentToBezierCache[argsString]) {70 return segmentToBezierCache[argsString];71 }72 var a00 = cos_th * rx;73 var a01 = -sin_th * ry;74 var a10 = sin_th * rx;75 var a11 = cos_th * ry;76 var th_half = 0.5 * (th1 - th0);77 var t = (8/3) * Math.sin(th_half * 0.5) *78 Math.sin(th_half * 0.5) / Math.sin(th_half);79 var x1 = cx + Math.cos(th0) - t * Math.sin(th0);80 var y1 = cy + Math.sin(th0) + t * Math.cos(th0);81 var x3 = cx + Math.cos(th1);82 var y3 = cy + Math.sin(th1);83 var x2 = x3 + t * Math.sin(th1);84 var y2 = y3 - t * Math.cos(th1);85 segmentToBezierCache[argsString] = [86 a00 * x1 + a01 * y1, a10 * x1 + a11 * y1,87 a00 * x2 + a01 * y2, a10 * x2 + a11 * y2,88 a00 * x3 + a01 * y3, a10 * x3 + a11 * y389 ];90 return segmentToBezierCache[argsString];91 }92 /**93 * Draws arc94 * @param {CanvasRenderingContext2D} ctx95 * @param {Number} x96 * @param {Number} y97 * @param {Array} coords98 */99 fabric.util.drawArc = function(ctx, x, y, coords) {100 var rx = coords[0];101 var ry = coords[1];102 var rot = coords[2];103 var large = coords[3];104 var sweep = coords[4];105 var ex = coords[5];106 var ey = coords[6];107 var segs = arcToSegments(ex, ey, rx, ry, large, sweep, rot, x, y);108 for (var i=0; i<segs.length; i++) {109 var bez = segmentToBezier.apply(this, segs[i]);110 ctx.bezierCurveTo.apply(ctx, bez);111 }112 };...
linter-vhdl-vcom.js
Source:linter-vhdl-vcom.js
1'use babel'2/* global atom */3import { exec } from 'child_process'4import { dirname } from 'path'5export default {6 name: 'VHDL Linter',7 scope: 'file', // or 'project'8 lintsOnChange: false, // or true9 grammarScopes: ['source.vhdl'],10 lint (textEditor) {11 const file = textEditor.getPath()12 const dirName = dirname(file)13 const projPath = atom.project.relativizePath(file)[0]14 const regex = /\*\*([^:]+):.*[^:]*\(([^)]+)\):(.+)/15 const workDir = atom.config.get('linter-vhdl-vcom.workDir')16 let argsString = ''17 atom.config.get('linter-vhdl-vcom.vcomOptions').forEach(function (arg) {18 argsString = `${argsString} ${arg}`19 })20 argsString = `${argsString} "${file}" -work "${workDir}"`21 atom.config.get('linter-vhdl-vcom.includePathsRelativeToTheProject').forEach(function (incPath) {22 argsString = `${argsString} +incdir+${projPath}/${incPath}`23 })24 atom.config.get('linter-vhdl-vcom.includePathsRelativeToTheSourceFile').forEach(function (incPath) {25 argsString = `${argsString} +incdir+${dirName}/${incPath}`26 })27 const options = {}28 // Do something async29 return new Promise(function (resolve) {30 var childProc31 try {32 childProc = exec(33 `vcom ${argsString}`,34 options35 )36 } catch (err) {37 // nothing to do here...38 }39 var messages = []40 var newMessage41 const ignoredCodes = atom.config.get('linter-vhdl-vcom.ignoredVcomErrorCodes')42 const readline = require('readline')43 const rl = readline.createInterface({44 input: childProc.stdout45 })46 function msgUnique (msg) {47 if (msg.location.file === newMessage.location.file && msg.location.position[0][0] === newMessage.location.position[0][0] &&48 msg.excerpt === newMessage.excerpt) {49 return false50 } else {51 return true52 }53 }54 function ignoreCode (line) {55 const codeMatch = line.match(/\(vcom-(\d+)\)/)56 var code57 if (!codeMatch) {58 return false59 } else {60 code = codeMatch[1]61 }62 for (var i = 0; i < ignoredCodes.length; i++) {63 if (ignoredCodes[i] === code) {64 return true65 }66 }67 return false68 }69 rl.on('line', function (line) {70 const parts = line.match(regex)71 if (!parts || parts.length !== 4) {72 if (line.match(/\*\* Error/)) {73 atom.notifications.addError(`linter-vhdl-vcom: vcom command died with this message: ${line}`, { dismissable: true })74 }75 } else if (!(ignoreCode(line))) {76 const lineNum = parseInt(parts[2])77 const msgSeverity = parts[1].trim().toLowerCase()78 const errorMsg = `${parts[1].trim()}: ${parts[3].trim()}`79 newMessage = {80 location: {81 file: file,82 position: [83 [lineNum - 1, 0],84 [lineNum - 1, 1000]85 ]86 },87 severity: msgSeverity,88 excerpt: errorMsg89 }90 // dont add duplicate messages91 if (messages.every(msgUnique)) {92 messages.push(newMessage)93 }94 }95 })96 function finishUp () {97 resolve(messages)98 }99 rl.on('finish', finishUp)100 rl.on('close', finishUp)101 })102 }...
Using AI Code Generation
1const argsString = require('storybook-root').argsString;2const argsString = require('storybook-root').argsString;3const argsString = require('storybook-root').argsString;4const argsString = require('storybook-root').argsString;5const argsString = require('storybook-root').argsString;6const argsString = require('storybook-root').argsString;7const argsString = require('storybook-root').argsString;8const argsString = require('storybook-root').argsString;9const argsString = require('storybook-root').argsString;10const argsString = require('storybook-root').argsString;11const argsString = require('storybook-root').argsString;12const argsString = require('storybook-root').argsString;13const argsString = require('storybook-root').argsString;14const argsString = require('storybook-root').argsString;15const argsString = require('storybook-root').argsString;16const argsString = require('storybook-root').argsString;17const argsString = require('storybook-root').argsString;18const argsString = require('storybook-root').argsString;19const argsString = require('storybook-root').argsString;
Using AI Code Generation
1const { argsString } = require('@storybook/addon-docs/blocks');2const argTypes = {3 arg1: { control: { type: 'text' } },4 arg2: { control: { type: 'text' } },5};6const Template = args => {7 const argsStr = argsString(args);8 return `<my-element ${argsStr}></my-element>`;9};10export const Story1 = Template.bind({});11Story1.args = {12};13Story1.argTypes = argTypes;14export const Story2 = Template.bind({});15Story2.args = {16};17Story2.argTypes = argTypes;18export default {19};20import { addParameters } from '@storybook/web-components';21import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks';22addParameters({23 docs: {24 },25});26import { LitElement, html } from 'lit-element';27class MyElement extends LitElement {28 static get properties() {29 return {30 arg1: { type: String },31 arg2: { type: String },32 };33 }34 render() {35 <div>arg1: ${this.arg1}</div>36 <div>arg2: ${this.arg2}</div>37 `;38 }39}40customElements.define('my-element', MyElement);41import { html } from 'lit-html';42import './my-element.js';43export default {44 argTypes: {45 arg1: { control: { type: 'text' } },46 arg2: { control: { type: 'text' } },47 },48};49const Template = ({ arg
Using AI Code Generation
1var argsString = require("storybook-root").argsString;2var args = argsString();3console.log(args);4var argsString = require("storybook-root").argsString;5var args = argsString();6console.log(args);7var argsString = require("storybook-root").argsString;8var args = argsString();9console.log(args);10var argsString = require("storybook-root").argsString;11var args = argsString();12console.log(args);13var argsString = require("storybook-root").argsString;14var args = argsString();15console.log(args);16var argsString = require("storybook-root").argsString;17var args = argsString();18console.log(args);19var argsString = require("storybook-root").argsString;20var args = argsString();21console.log(args);22var argsString = require("storybook-root").argsString;23var args = argsString();24console.log(args);25var argsString = require("storybook-root").argsString;26var args = argsString();27console.log(args);28var argsString = require("storybook-root").argsString;29var args = argsString();30console.log(args);
Using AI Code Generation
1const argsString = require('storybook-root').argsString;2const args = argsString(process.argv);3console.log(args);4{ _: [], a: 1, b: 2 }5{ _: [], a: 1, b: 2, c: 3 }6{ _: [], a: 1, b: 2, c: 3, d: 4 }7{ _: [], a: 1, b: 2, c: 3, d: 4, e: 5 }8{ _: [], a: 1, b: 2, c: 3, d: 4, e: 5, f: 6 }9{ _: [], a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7 }10{ _: [], a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8 }11{ _: [], a: 1
Using AI Code Generation
1import React from 'react';2import { render } from '@testing-library/react';3import { StorybookRoot } from '@storybook/react';4import { withKnobs } from '@storybook/addon-knobs';5import { withDesign } from 'storybook-addon-designs';6import { withA11y } from '@storybook/addon-a11y';7import { withTests } from '@storybook/addon-jest';8import { withPerformance } from 'storybook-addon-performance';9import { withConsole } from '@storybook/addon-console';10import { withInfo } from '@storybook/addon-info';11import { withContexts } from '@storybook/addon-contexts';12import { withViewport } from '@storybook/addon-viewport';13import { contexts } from './contexts';14import { testResults } from '../../../.jest-test-results.json';15import { Button } from './Button';16 withTests({ results: testResults }),17 withContexts(contexts),18];19const parameters = {20 design: {21 },22 viewport: {23 viewports: {24 iphone5: {25 styles: {26 },27 },28 iphone6: {29 styles: {30 },31 },32 iphoneplus: {33 styles: {34 },35 },36 iphonex: {37 styles: {38 },39 },40 },41 },42};43export default {
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!!