Best JavaScript code snippet using wpt
css-style-value.js
Source:css-style-value.js
1// Copyright 2016 Google Inc. All rights reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14suite('CSSStyleValue', function() {15 test('parse works for keywords', function() {16 var keywordValue = CSSStyleValue.parse('height', 'auto');17 assert.strictEqual(keywordValue.cssText, 'auto');18 });19 test('parse works for lengths', function() {20 var value = CSSStyleValue.parse('height', 'calc(10px + 3em)');21 assert.strictEqual(value.cssText, 'calc(10px + 3em)');22 assert.strictEqual(value.px, 10);23 assert.strictEqual(value.em, 3);24 value = CSSStyleValue.parse('height', '11px');25 assert.strictEqual(value.cssText, '11px');26 assert.strictEqual(value.value, 11);27 assert.strictEqual(value.type, 'px');28 });29 test('parse works for numbers', function() {30 var value = CSSStyleValue.parse('opacity', '0.3');31 assert.strictEqual(value.cssText, '0.3');32 assert.strictEqual(value.value, 0.3);33 });34 test('parse works for transform(translate)', function() {35 var value = CSSStyleValue.parse('transform', 'translate(10px)');36 // TODO: Change cssText for CSSTranslation so that it reflects parsed string.37 assert.strictEqual(value.cssText, 'translate(10px, 0px)');38 assert.instanceOf(value.transformComponents[0], CSSTranslation);39 assert.strictEqual(value.transformComponents[0].x.value, 10);40 assert.strictEqual(value.transformComponents[0].x.type, 'px');41 assert.strictEqual(value.transformComponents[0].y.value, 0);42 assert.strictEqual(value.transformComponents[0].y.type, 'px');43 // TODO: Change this to something sensible. Udate spec?44 assert.isNull(value.transformComponents[0].z);45 value = CSSStyleValue.parse('transform', 'translatez(1px)');46 assert.strictEqual(value.cssText, 'translate3d(0px, 0px, 1px)');47 assert.instanceOf(value.transformComponents[0], CSSTranslation);48 assert.strictEqual(value.transformComponents[0].x.value, 0);49 assert.strictEqual(value.transformComponents[0].x.type, 'px');50 assert.strictEqual(value.transformComponents[0].y.value, 0);51 assert.strictEqual(value.transformComponents[0].y.type, 'px');52 assert.strictEqual(value.transformComponents[0].z.value, 1);53 assert.strictEqual(value.transformComponents[0].y.type, 'px');54 });55 test('parse works for transform(skew)', function() {56 var value = CSSStyleValue.parse('transform', 'skewx(10rad)');57 assert.strictEqual(value.cssText, 'skewx(10rad)');58 assert.instanceOf(value.transformComponents[0], CSSSkew);59 assert.strictEqual(value.transformComponents[0].ax.radians, 10);60 assert.strictEqual(value.transformComponents[0].ay.degrees, 0);61 value = CSSStyleValue.parse('transform', 'skew(1rad, 30deg)');62 assert.strictEqual(value.cssText, 'skew(1rad, 30deg)');63 assert.instanceOf(value.transformComponents[0], CSSSkew);64 assert.strictEqual(value.transformComponents[0].ax.radians, 1);65 assert.strictEqual(value.transformComponents[0].ay.degrees, 30);66 value = CSSStyleValue.parse('transform', 'skew(0.5turn)');67 assert.strictEqual(value.cssText, 'skew(0.5turn)');68 assert.instanceOf(value.transformComponents[0], CSSSkew);69 assert.strictEqual(value.transformComponents[0].ax.degrees, 180);70 assert.strictEqual(value.transformComponents[0].ay.degrees, 0);71 });72 test('parse works for transform(rotate)', function() {73 var value = CSSStyleValue.parse('transform', 'rotate(1rad)');74 assert.strictEqual(value.cssText, 'rotate(1rad)');75 assert.instanceOf(value.transformComponents[0], CSSRotation);76 assert.strictEqual(value.transformComponents[0].angle.radians, 1);77 value = CSSStyleValue.parse('transform', 'rotate3d(1, 1, 1, 15deg)');78 assert.strictEqual(value.cssText, 'rotate3d(1, 1, 1, 15deg)');79 assert.instanceOf(value.transformComponents[0], CSSRotation);80 assert.strictEqual(value.transformComponents[0].x, 1);81 assert.strictEqual(value.transformComponents[0].y, 1);82 assert.strictEqual(value.transformComponents[0].z, 1);83 assert.strictEqual(value.transformComponents[0].angle.degrees, 15);84 });85 test('parse works for transform(scale)', function() {86 var value = CSSStyleValue.parse('transform', 'scale(2)');87 // TODO: Change cssText for CSSScale so that it reflects parsed string.88 assert.strictEqual(value.cssText, 'scale(2, 2)');89 assert.instanceOf(value.transformComponents[0], CSSScale);90 assert.strictEqual(value.transformComponents[0].x, 2);91 assert.strictEqual(value.transformComponents[0].y, 2);92 // TODO: Change this to something sensible. Udate spec?93 assert.isNull(value.transformComponents[0].z);94 value = CSSStyleValue.parse('transform', 'scaley(2)');95 assert.strictEqual(value.cssText, 'scale(1, 2)');96 assert.instanceOf(value.transformComponents[0], CSSScale);97 assert.strictEqual(value.transformComponents[0].x, 1);98 assert.strictEqual(value.transformComponents[0].y, 2);99 assert.isNull(value.transformComponents[0].z);100 value = CSSStyleValue.parse('transform', 'scalez(2)');101 assert.strictEqual(value.cssText, 'scale3d(1, 1, 2)');102 assert.instanceOf(value.transformComponents[0], CSSScale);103 assert.strictEqual(value.transformComponents[0].x, 1);104 assert.strictEqual(value.transformComponents[0].y, 1);105 assert.strictEqual(value.transformComponents[0].z, 2);106 });107 test('parse works for transform(matrix)', function() {108 var value = CSSStyleValue.parse('transform', 'matrix(2, 0, 2, 2, 0, 0)');109 assert.strictEqual(value.cssText, 'matrix(2, 0, 2, 2, 0, 0)');110 assert.instanceOf(value.transformComponents[0], CSSMatrix);111 typedOM.internal.testing.matricesApproxEqual(value.transformComponents[0].matrix, new DOMMatrixReadonly([2, 0, 2, 2, 0, 0]));112 value = CSSStyleValue.parse('transform', 'matrix3d(1, 2, 3, 4, 5, 6, 7, 8.6, 9, 10, 11, 12, 13, 14, 15, 16)');113 assert.strictEqual(value.cssText, 'matrix3d(1, 2, 3, 4, 5, 6, 7, 8.6, 9, 10, 11, 12, 13, 14, 15, 16)');114 assert.instanceOf(value.transformComponents[0], CSSMatrix);115 typedOM.internal.testing.matricesApproxEqual(value.transformComponents[0].matrix, new DOMMatrixReadonly([1, 2, 3, 4, 5, 6, 7, 8.6, 9, 10, 11, 12, 13, 14, 15, 16]));116 });117 test('parse works for transform(perspective)', function() {118 var value = CSSStyleValue.parse('transform', 'perspective(10px)');119 assert.strictEqual(value.cssText, 'perspective(10px)');120 assert.instanceOf(value.transformComponents[0], CSSPerspective);121 assert.strictEqual(value.transformComponents[0].length.value, 10);122 assert.strictEqual(value.transformComponents[0].length.type, 'px');123 });124 test('parse should be case insensitive', function() {125 var value = CSSStyleValue.parse('height', 'CaLc(10px + 3em)');126 assert.strictEqual(value.cssText, 'calc(10px + 3em)');127 });128 test('parse throws an error if either the property or the cssText is not a string', function() {129 assert.throws(function() {CSSStyleValue.parse(4, 'auto')}, TypeError, /^Property name must be a string/);130 assert.throws(function() {CSSStyleValue.parse('height', 5)}, TypeError, /^Must parse a string/);131 });132 test('parse returns null if an unsupported property is entered', function() {133 assert.isNull(CSSStyleValue.parse('lemons', '10px'));134 });135 test('parse returns null if a cssText representing a CSSStyleValue type unsupported by a property is entered', function() {136 assert.isNull(CSSStyleValue.parse('height', '10'));137 });138 test('instantiating CSSStyleValue throws', function() {139 assert.throws(function() {new CSSStyleValue('10px')}, TypeError, 'CSSStyleValue cannot be instantiated.');140 });141 test('internal.CSSStyleValue can be constructed and appears to be a regular CSSStyleValue', function() {142 var internalStyleValue;143 assert.doesNotThrow(function() { internalStyleValue = new typedOM.internal.CSSStyleValue('foo'); });144 assert.strictEqual(internalStyleValue.cssText, 'foo');145 assert.strictEqual(internalStyleValue.constructor, CSSStyleValue);146 });147 test('parse successfully creates an array of CSSStyleValue objects if the cssText is a valid list of values ' +148 'for a property', function() {149 var keywordValueArray = CSSStyleValue.parse('animation-iteration-count', 'infinite, 4, 5, 7, 9');150 assert.deepEqual(keywordValueArray, [new CSSKeywordValue('infinite'), new CSSNumberValue(4), new CSSNumberValue(5), new CSSNumberValue(7), new CSSNumberValue(9)]);151 });...
css-transform-value.js
Source:css-transform-value.js
1// Copyright 2015 Google Inc. All rights reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14(function(internal, scope) {15 function computeMatrix(cssTransform) {16 if (!cssTransform.transformComponents.length) {17 return new DOMMatrixReadonly([1, 0, 0, 1, 0, 0]);18 }19 var matrix = cssTransform.transformComponents[0].matrix;20 for (var i = 1; i < cssTransform.transformComponents.length; ++i) {21 matrix = matrix.multiply(cssTransform.transformComponents[i].matrix);22 }23 return matrix;24 };25 function generateCssString(cssTransform) {26 function getCssString(value) {27 return value.cssText;28 }29 return cssTransform.transformComponents.map(getCssString).join(' ');30 };31 function CSSTransformValue(values) {32 if (values === undefined) {33 values = [];34 }35 if (!Array.isArray(values)) {36 throw new TypeError('CSSTransformValue must have an array ' +37 'of CSSTransformComponents or must be empty');38 }39 // TODO(wilddamon): transformComponents shouldn't be public. Users should use the iterable syntax instead.40 this.transformComponents = [];41 for (var i = 0; i < values.length; i++) {42 if (!(values[i] instanceof internal.CSSTransformComponent)) {43 throw new TypeError('Argument at index ' + i + ' is not an instance ' +44 'of \'CSSTransformComponent\'.');45 }46 this.transformComponents.push(values[i]);47 }48 this.matrix = computeMatrix(this);49 this.is2D = this.matrix.is2D;50 this.cssText = generateCssString(this);51 }52 internal.inherit(CSSTransformValue, CSSStyleValue);53 CSSTransformValue.prototype[Symbol.iterator] = function() {54 return this.entries();55 };56 CSSTransformValue.prototype.entries = function() {57 function entriesCallback(index) {58 return [index, this.transformComponents[index]];59 }60 return internal.objects.arrayIterator(61 this.transformComponents.length,62 entriesCallback.bind(this));63 };64 CSSTransformValue.prototype.keys = function() {65 return internal.objects.arrayIterator(66 this.transformComponents.length,67 function(index) { return index; });68 };69 CSSTransformValue.prototype.values = function() {70 function valuesCallback(index) {71 return this.transformComponents[index];72 }73 return internal.objects.arrayIterator(74 this.transformComponents.length,75 valuesCallback.bind(this));76 };77 scope.CSSTransformValue = CSSTransformValue;...
index.ts
Source:index.ts
...4// export { default as CollapseTransition } from './src/Collapse.vue';5export { default as CollapseTransition } from './src/CollapseTransition.vue';6// export const CollapseTransition = getAsyncComponent(() => import('./src/CollapseTransition.vue'));7// Component specific transitions8export const FadeTransition = transformComponents(createSimpleTransition('fade-transition'));9export const ScaleTransition = transformComponents(createSimpleTransition('scale-transition'));10export const SlideYTransition = transformComponents(createSimpleTransition('slide-y-transition'));11export const ScrollYTransition = transformComponents(createSimpleTransition('scroll-y-transition'));12export const SlideYReverseTransition = transformComponents(13 createSimpleTransition('slide-y-reverse-transition')14);15export const ScrollYReverseTransition = transformComponents(16 createSimpleTransition('scroll-y-reverse-transition')17);18export const SlideXTransition = transformComponents(createSimpleTransition('slide-x-transition'));19export const ScrollXTransition = transformComponents(createSimpleTransition('scroll-x-transition'));20export const SlideXReverseTransition = transformComponents(21 createSimpleTransition('slide-x-reverse-transition')22);23export const ScrollXReverseTransition = transformComponents(24 createSimpleTransition('scroll-x-reverse-transition')25);26export const ScaleRotateTransition = transformComponents(27 createSimpleTransition('scale-rotate-transition')28);29// Javascript transitions30export const ExpandTransition = transformComponents(31 createJavascriptTransition('expand-transition', ExpandTransitionGenerator())32);33export const ExpandXTransition = transformComponents(34 createJavascriptTransition('expand-x-transition', ExpandTransitionGenerator('', true))...
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var path = require('path');3var fs = require('fs');4var inputDir = path.join(__dirname, 'input');5var outputDir = path.join(__dirname, 'output');6var options = {7 templateDir: path.join(__dirname, 'templates'),8};9wptoolkit.generate(options, function (err) {10 if (err) {11 console.log(err);12 } else {13 console.log('Completed!');14 }15});16### wptoolkit.generate(options, callback)17MIT © [Karthik Rajendran](
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.transformComponents('www.google.com', function(err, data) {4 if(err) return console.error(err);5 console.log(data);6});7{8 "data": {9 "testinfo": {
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var path = require('path');3var fs = require('fs');4var componentDir = path.join(__dirname, 'components');5var outputDir = path.join(__dirname, 'output');6wptoolkit.transformComponents(componentDir, outputDir, function (err, result) {7 if (err) {8 console.log('Error: ' + err);9 } else {10 console.log('Success: ' + result);11 }12});13var comp1 = {14 data: function () {15 return {16 };17 }18};19module.exports = comp1;20var comp1 = {21 data: function () {22 return {23 };24 }25};26module.exports = comp1;27var comp2 = {28 data: function () {29 return {30 };31 }32};33module.exports = comp2;34var comp2 = {35 data: function () {36 return {37 };38 }39};40module.exports = comp2;41var comp3 = {42 data: function () {43 return {44 };45 }46};47module.exports = comp3;48var comp3 = {49 data: function () {50 return {
Using AI Code Generation
1var wpt = require('webpagetest');2var wptClient = wpt('www.webpagetest.org');3 if(err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('webpagetest');10var wptClient = wpt('www.webpagetest.org');11 if(err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = require('webpagetest');18var wptClient = wpt('www.webpagetest.org');19 if(err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('webpagetest');26var wptClient = wpt('www.webpagetest.org');27 if(err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var wpt = require('webpagetest');34var wptClient = wpt('www.webpagetest.org');35 if(err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('webpagetest');42var wptClient = wpt('www.webpagetest.org');
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3var input = fs.readFileSync('input.json');4var inputJson = JSON.parse(input);5var outputJson = wptools.transformComponents(inputJson);6var output = JSON.stringify(outputJson);7fs.writeFileSync('output.json', output);8var fs = require('fs');9var input = [{10 "props": {11 "onClick": "function handleClick() {\n alert('You clicked the button');\n}",12 },13}, {14 "props": {15 "onClick": "function handleClick() {\n alert('You clicked the button');\n}",16 },17}, {18 "props": {19 "onClick": "function handleClick() {\n alert('You clicked the button');\n}",20 },21}];22var inputJson = JSON.stringify(input);23fs.writeFileSync('input.json', inputJson);24 {25 "props": {26 "onClick": "function handleClick() {\n alert('You clicked the button');\n}",27 },28 },29 {30 "props": {31 "onClick": "function handleClick() {\n alert('You clicked the button');\n}",32 },33 },34 {35 "props": {36 "onClick": "function handleClick() {\n alert('You clicked the button');\n}",37 },38 }39[MIT](LICENSE)
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var path = require('path');3var fs = require('fs');4var componentDir = path.join(__dirname, 'components');5var outputDir = path.join(__dirname, 'output');6var options = {7};8wptoolkit.transformComponents(componentDir, options, function(err) {9 if (err) {10 console.error(err);11 } else {12 console.log('Components transformed successfully!');13 }14});15var myComponent = require('./my-component');16module.exports = myComponent;17 Polymer({18 });
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var fs = require('fs');3var path = require('path');4var wp = new wptoolkit();5var config = {6 "components": {7 "test": {8 }9 }10};11var options = {12};13wp.transformComponents(options, function(err, result) {14 if (err) {15 console.log(err);16 } else {17 console.log(result);18 }19});20### transformComponents(options, callback)21### transformComponent(options, callback)22### transformComponent(options, callback)
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3var w = wptools.page('Wikipedia:WikiProject_Music/Assessments');4w.get(function(err, resp) {5 if (err) {6 console.log(err);7 return;8 }9 var html = resp.parse.text['*'];10 var components = w.transformComponents(html);11 fs.writeFileSync('test.json', JSON.stringify(components, null, 2));12});13{14 {
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var wp = new wptoolkit();3var component = {4 "dependencies": {5 },6 "devDependencies": {},7 "scripts": {8 },9 "repository": {
Using AI Code Generation
1const wptools = require('wptools');2wptools.transformComponents('en', 'Main Page').then(console.log);3#### wptools.transformComponents(lang, title, options)4 * `section` - Section number to transform. Default is `0` (all sections)5### wptools.getCategories(lang, title, options)6### wptools.getImages(lang, title, options)
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!!