Best JavaScript code snippet using storybook-root
MISGrid.js
Source:MISGrid.js
1(function ($) {2 $.fn.extend({3 MISGrid: function (option,filterOption=false) {4 try {5 var defaults = {6 Container: '.table',7 //height: '40vh',8 width: null,9 parent: 'body',10 rowCondintion: null,11 rowsGroup: null,12 gridUrl: null,13 data: null,14 axis: null,15 hideColumn: null,16 scrollColor: '#F44917',17 paging: false,18 pageLength: 100,19 AjaxType: "GET",20 DataAsync: true,21 };22 var MISGrid = {};23 MISGrid.Grid = null;24 MISGrid.DataCount = 0;25 var context = $(this);26 var extendOptions = $.extend(defaults, option);27 var ajaxOpt =28 {29 type: 'GET',30 contentType: 'application/json; charset=utf-8',31 url: baseURL + extendOptions.gridUrl,32 global:true,33 async: extendOptions.DataAsync,34 type: extendOptions.AjaxType,35 dataType: 'json',36 success: function (data) {37 MISGrid.DataCount = data.length;38 if (data.length > 0) {39 setTimeout(function () {40 PopulateSkillMappingDetailsList(data);41 if (extendOptions.onLoadComplete != undefined)42 extendOptions.onLoadComplete(MISGrid.Grid, data);43 MISGrid.Grid.columns.adjust();44 MISGrid.Grid.columns.adjust();45 //if (extendOptions.height != null) {46 // var temThead = context.closest('.dataTables_scroll').find('.dataTables_scrollHeadInner thead tr');47 // //temThead.empty();48 // var tr = "<tr>";49 // var contextThead = context.find('tbody tr');50 // contextThead.find('td').each(function (index)51 // {52 // temThead.find('th')[index].height = $(this).height();53 // });54 // // tr += '</tr>';55 // // context.closest('.dataTables_scroll').find('.dataTables_scrollHeadInner thead').html(tr);56 //}57 }, 500);58 }59 else {60 $.growl.notice({ title: "Message", location: "bl", message: "No Data Found" });61 }62 }, error: function (data) {63 console.log(data);64 }65 };66 if (extendOptions.DataParam != null)67 ajaxOpt.data = extendOptions.DataParam;68 if (extendOptions.gridUrl != null)69 $.ajax(ajaxOpt);70 if (extendOptions.data != null && extendOptions.data.length > 0) {71 PopulateSkillMappingDetailsList(extendOptions.data);72 if (extendOptions.onLoadComplete != undefined)73 extendOptions.onLoadComplete(MISGrid.Grid, extendOptions.data);74 }75 }76 catch (ex) {77 console.log(ex);78 }79 function PopulateSkillMappingDetailsList(data) {80 if (MISGrid.Grid != undefined) {81 MISGrid.Grid.destroy().draw(false);82 context.empty();83 }84 var columnsName = [];85 //columnsName.push({ 'title': 'CATEGORY','name':'mCategory','width':'15px'});86 var count = 1;87 for (var prop in data[0].Columns) {88 //itemArray.push(BusinessPlan[i].Months[prop]);89 if (extendOptions.hideColumn != null && extendOptions.hideColumn.indexOf(prop) > -1)90 continue;91 //columnsName.push({ 'title': '' + prop + '', 'name': prop, "visible": false, })//className: "hide_column"92 columnsName.push({ 'title': '' + prop + '', 'name': prop });93 }94 var DataArray = [];95 for (var i = 0; i < data.length; i++) {96 var item = data[i];97 var itemArray = [];98 for (var prop in data[i].Columns) {99 if (extendOptions.hideColumn != null && extendOptions.hideColumn.indexOf(prop) > -1)100 continue;101 itemArray.push(Number(data[i].Columns[prop]) == 0 ? "" : data[i].Columns[prop]);102 }103 DataArray.push(itemArray);104 }105 var aoColumnDefs = [];106 for (var i = 0; i < columnsName.length; i++) {107 aoColumnDefs.push(i);108 }109 var dataSource = data;110 var dataTableOpt = {111 createdRow: function (row, data, dataIndex) {112 if (extendOptions.rowCondintion != null) {113 extendOptions.rowCondintion(row, data, columnsName, dataSource[dataIndex]);114 }115 },116 destroy: true,117 data: DataArray,118 "bFilter": filterOption,119 "bInfo": false,120 "bSort": false,121 paging: extendOptions.paging,122 "pageLength": extendOptions.pageLength,123 "bLengthChange": false,124 orderable: false,125 responsive: true,126 //"bAutoWidth": false,127 scrollCollapse: false,128 "bProcessing": false,129 "aoColumnDefs": [{ "bSortable": false, "aTargets": aoColumnDefs }],130 columns: columnsName,131 "initComplete": function () {132 //if (extendOptions.onLoadComplete != undefined)133 // extendOptions.onLoadComplete(MISGrid.Grid);134 }135 };136 if (extendOptions.rowsGroup != null)137 dataTableOpt.rowsGroup = extendOptions.rowsGroup;138 if (extendOptions.height != null) {139 dataTableOpt.scrollY = extendOptions.height;140 dataTableOpt["initComplete"] = function () {141 //context.find('thead th').empty();142 };143 }144 if (extendOptions.width != null) {145 dataTableOpt.scrollX = true;146 //dataTableOpt.sScrollX = "100%";147 }148 MISGrid.Grid = $(context).DataTable(dataTableOpt);149 //$(context).on('draw.dt', function () {150 // $('.dataTables_scrollBody thead tr').addClass('hidden')151 //});152 if (extendOptions.axis != null) {153 //if (extendOptions.axis == 'both') {154 // $('' + extendOptions.parent + ' .dataTables_scrollBody').slimScroll({155 // axis: 'both', height: extendOptions.height, alwaysVisible: true,156 // width: '100%', wheelStep: 150, color: extendOptions.scrollColor, opacity: 0.7, size: '10px', allowPageScroll: false157 // });158 //}159 //if (extendOptions.axis == 'x') {160 // $('' + extendOptions.parent + ' .dataTables_scrollBody').slimScroll({161 // axis: 'x', alwaysVisible: true,162 // width: '100%', wheelStep: 150, color: extendOptions.scrollColor, opacity: 0.7, size: '10px', allowPageScroll: false163 // });164 //}165 //if (extendOptions.axis == 'y') {166 // $('' + extendOptions.parent + ' .dataTables_scrollBody').slimScroll({167 // axis: 'y', height: extendOptions.height, alwaysVisible: true, width: extendOptions.width,168 // wheelStep: 150, color: extendOptions.scrollColor, opacity: 0.7, size: '10px', allowPageScroll: false169 // });170 //}171 }172 }173 $.fn.misGrid = MISGrid;174 return $.fn.misGrid;175 }176 });177}...
parse_config_file.ts
Source:parse_config_file.ts
1import {Headers, RequestOptions, ResponseType, SearchParamsType} from "@thekla/config"2import {ExtendOptions} from "got";3import {HttpProxyAgent, HttpsProxyAgent} from "hpagent";4import {curry, merge, pipe} from "ramda";5type CurriedOptionsFunc<T> = (arg: T) => (gotOpts: ExtendOptions) => ExtendOptions;6type JsonBody = { [key: string]: any; }7export const createGotOptions = (reqOpts: RequestOptions): ExtendOptions => {8 return pipe(9 reqOpts.baseUrl ? setBaseUrl(reqOpts.baseUrl) : identity(reqOpts),10 reqOpts.port ? setPort(reqOpts.port) : identity(reqOpts),11 reqOpts.headers ? setHeaders(reqOpts.headers) : identity(reqOpts),12 reqOpts.textBody ? setTextBody(reqOpts.textBody) : identity(reqOpts),13 reqOpts.jsonBody ? setJsonBody(reqOpts.jsonBody) : identity(reqOpts),14 reqOpts.responseType ? setResponseType(reqOpts.responseType) : identity(reqOpts),15 reqOpts.searchParams ? setSearchParams(reqOpts.searchParams) : identity(reqOpts),16 reqOpts.resolveBodyOnly ? setResolveBodyOnly(reqOpts.resolveBodyOnly) : identity(reqOpts),17 // proxy shall be last to add18 reqOpts.proxy ? setProxy(reqOpts.proxy) : identity(reqOpts)19 )({})20}21const identity: CurriedOptionsFunc<RequestOptions> = curry((reqOpts: RequestOptions, gotOpts: ExtendOptions): ExtendOptions => {22 return gotOpts23})24const setBaseUrl: CurriedOptionsFunc<string> = curry((baseUrl: string, gotOpts: ExtendOptions): ExtendOptions => {25 return merge(gotOpts, {prefixUrl: baseUrl});26})27const setPort: CurriedOptionsFunc<string | number> = curry((port: string | number, gotOpts: ExtendOptions): ExtendOptions => {28 return merge(gotOpts, {port: port});29})30const setTextBody: CurriedOptionsFunc<string> = curry((textBody: string, gotOpts: ExtendOptions): ExtendOptions => {31 return merge(gotOpts, {body: textBody});32})33const setJsonBody: CurriedOptionsFunc<JsonBody> = curry((jsonBody: JsonBody, gotOpts: ExtendOptions): ExtendOptions => {34 return merge(gotOpts, {json: jsonBody});35})36const setResponseType: CurriedOptionsFunc<ResponseType> = curry((responseType: ResponseType, gotOpts: ExtendOptions): ExtendOptions => {37 return merge(gotOpts, {responseType: responseType});38})39const setSearchParams: CurriedOptionsFunc<SearchParamsType> = curry((searchParams: SearchParamsType, gotOpts: ExtendOptions): ExtendOptions => {40 return merge(gotOpts, {searchParams: searchParams});41})42const setResolveBodyOnly: CurriedOptionsFunc<boolean> = curry((bodyOnly: boolean, gotOpts: ExtendOptions): ExtendOptions => {43 return merge(gotOpts, {resolveBodyOnly: bodyOnly});44})45const setHeaders: CurriedOptionsFunc<Headers> = curry((headers: Headers, gotOpts: ExtendOptions): ExtendOptions => {46 return merge(gotOpts, {headers: headers});47})48const setProxy: CurriedOptionsFunc<string> = curry((proxyUrl: string, gotOpts: ExtendOptions): ExtendOptions => {49 const httpProxy = {50 agent: {51 http: new HttpProxyAgent({52 keepAlive: true,53 keepAliveMsecs: 1000,54 maxSockets: 256,55 maxFreeSockets: 256,56 proxy: proxyUrl57 })58 }59 }60 const httpsProxy = {61 agent: {62 http: new HttpsProxyAgent({63 keepAlive: true,64 keepAliveMsecs: 1000,65 maxSockets: 256,66 maxFreeSockets: 256,67 proxy: proxyUrl68 })69 }70 }71 return merge(gotOpts, proxyUrl.startsWith(`https`) ? httpsProxy : httpProxy);...
extend.js
Source:extend.js
1/* @flow */2import config from '../config'3import { warn, mergeOptions } from '../util/index'4export function initExtend (Vue: GlobalAPI) {5 /**6 * Each instance constructor, including Vue, has a unique7 * cid. This enables us to create wrapped "child8 * constructors" for prototypal inheritance and cache them.9 */10 Vue.cid = 011 let cid = 112 /**13 * Class inheritance14 */15 Vue.extend = function (extendOptions: Object): Function {16 extendOptions = extendOptions || {}17 const Super = this18 const isFirstExtend = Super.cid === 019 if (isFirstExtend && extendOptions._Ctor) {20 return extendOptions._Ctor21 }22 let name = extendOptions.name || Super.options.name23 if (process.env.NODE_ENV !== 'production') {24 if (!/^[a-zA-Z][\w-]*$/.test(name)) {25 warn(26 'Invalid component name: "' + name + '". Component names ' +27 'can only contain alphanumeric characaters and the hyphen.'28 )29 name = null30 }31 }32 const Sub = function VueComponent (options) {33 this._init(options)34 }35 Sub.prototype = Object.create(Super.prototype)36 Sub.prototype.constructor = Sub37 Sub.cid = cid++38 Sub.options = mergeOptions(39 Super.options,40 extendOptions41 )42 Sub['super'] = Super43 // allow further extension44 Sub.extend = Super.extend45 // create asset registers, so extended classes46 // can have their private assets too.47 config._assetTypes.forEach(function (type) {48 Sub[type] = Super[type]49 })50 // enable recursive self-lookup51 if (name) {52 Sub.options.components[name] = Sub53 }54 // keep a reference to the super options at extension time.55 // later at instantiation we can check if Super's options have56 // been updated.57 Sub.superOptions = Super.options58 Sub.extendOptions = extendOptions59 // cache constructor60 if (isFirstExtend) {61 extendOptions._Ctor = Sub62 }63 return Sub64 }...
Using AI Code Generation
1import { extendOptions } from 'storybook-root';2extendOptions({3 theme: {4 },5});6import '../test.js';
Using AI Code Generation
1const { extendOptions } = require('@storybook/react');2extendOptions({3 theme: {4 },5});6import { configure } from '@storybook/react';7import { setOptions } from '@storybook/addon-options';8setOptions({9 theme: {10 },11});12configure(() => require('../stories'), module);13import { configure } from '@storybook/react';14import { setOptions } from '@storybook/addon-options';15setOptions({16 theme: {17 },18});19configure(() => require('../stories'), module);20import { configure } from '@storybook/react';21import { setOptions } from '@storybook/addon-options';22setOptions({23 theme: {
Using AI Code Generation
1import { extendOptions } from 'storybook-root';2extendOptions({3 theme: {4 },5});6import '../test.js';
Using AI Code Generation
1import { extendOptions } from 'storybook-root'2extendOptions({3})4import { extendOptions } from 'storybook-root'5extendOptions({6})7import { extendOptions } from 'storybook-root'8extendOptions({9})10import { extendOptions } from 'storybook-root'11extendOptions({12})13import { extendOptions } from 'storybook-root'14extendOptions({15})16import { extendOptions } from 'storybook-root'17extendOptions({18 theme: {
Using AI Code Generation
1const { extendOptions } = require('@storybook/core/server');2extendOptions({3});4import { addons } from '@storybook/addons';5import { themes } from '@storybook/theming';6addons.setConfig({7});
Using AI Code Generation
1const { extendOptions } = require('storybook-root');2module.exports = extendOptions({3});4const path = require('path');5const { extendOptions } = require('storybook-root');6const { getStorybookRootOptions } = require('storybook-root');7const { getStorybookRootOptions } = require('storybook-root');8const { getStorybookRootOptions } = require('storybook-root');9module.exports = {10 ...getStorybookRootOptions(),11};12{13 "scripts": {14 }15}
Using AI Code Generation
1const { extendOptions } = require('storybook-root');2module.exports = extendOptions({3});4const path = require('path');5const { extendOptions } = require('storybook-root');6const { getStorybookRootOptions } = require('storybook-root');7const { getStorybookRootOptions } = require('storybook-root');8const { getStorybookRootOptions } = require('storybook-root');9module.exports = {10 ...getStorybookRootOptions(),11};12{13 "scripts": {14 }15}
Using AI Code Generation
1const { extendOptions } = require('@storybook/core/server');2extendOptions({3});4import { addons } from '@storybook/addons';5import { themes } from '@storybook/theming';6addons.setConfig({7});
Using AI Code Generation
1import { extendOptions } from 'storybook-root';2extendOptions({3});4import { loadStories } from 'storybook-root';5loadStories();6import { loadWebpackConfig } from 'storybook-root';7module.exports = loadWebpackConfig();
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!!