Skip to content

Instantly share code, notes, and snippets.

View gist:889b660840b858034447e1b0a102b7de
/**
* Linear search is a very simple search algorithm.
* In this type of search, a sequential search is made over all items one by one.
* Every item is checked and if a match is found then that particular item is returned,
* otherwise the search continues till the end of the data collection.
* @param {*} arr : An array in which you want to search the value
* @param {*} valueToSearch : value to be search in array
*/
function linearSearch(arr , valueToSearch){
@niteshpsit1
niteshpsit1 / sortings
Last active Mar 25, 2017
sorting programs
View sortings
let arrayToBeSort = [12,45,75,35,55,54,2,21]
// ## Bubble Sort
/**
*
* Bubble sort is a simple sorting algorithm.
* This sorting algorithm is comparison-based algorithm
* in which each pair of adjacent elements is compared
* and the elements are swapped if they are not in order.
* This algorithm is not suitable for large data sets as
View Auto test generate
var chokidar = require('chokidar');
var fs = require('fs')
var path = require('path')
var testFileExtension = 'spec.js'
var ignorefile = [/[\/\\]\./, 'package.json', 'node_modules', 'watcher.js'];
/**
* @getTemplate A function to get Tempate content for new test file
* @filename It just take on argument that is file
* @returns : string
**/
View gist:14079bd67408b1c4a301cfcd22c29034
var fs = require('fs')
var path = require('path')
/**
* function To generate the descption for test
* @param { String } filename name of api for which we need to generate test cases
* @returns { String } template for test cases
**/
function getTestTemplate(endpoint, httpMethod = 'GET') {
endpoint = JSON.stringify(endpoint)
return `var chai = require('chai');
@niteshpsit1
niteshpsit1 / gist:c90b3336ee639c89ae13b98825c9d9ca
Created Dec 1, 2016
Sorting an array order by frequency of occurence in javascript
View gist:c90b3336ee639c89ae13b98825c9d9ca
/**
* Sorting an array order by frequency of occurence in javascript
* @param {array} array An array to sort
* @returns {array} array of item order by frequency
**/
function sortByFrequency(array) {
var frequency = {};
var sortAble = [];
var newArr = [];
You can’t perform that action at this time.