Skip to content

Instantly share code, notes, and snippets.

View ganeshrvel's full-sized avatar

Ganesh Rathinavel Medayil ganeshrvel

View GitHub Profile
@ganeshrvel
ganeshrvel / checkIf.js
Created November 24, 2020 16:39
checkIf
import { assert } from '@sindresorhus/is';
import { IS_PROD } from '../constants/env';
/**
* description - Validate the types. In production mode the validation will be skipped
*
* @param value - variable
* @param {'string'|'boolean'|'number'|'numericString'|'array'|'function'|'object'|'undefinedOrNull'|'undefined'|'null'} type - type to compare
*
* @return {boolean}
@ganeshrvel
ganeshrvel / file-path-sorting.js
Created August 24, 2020 08:17
Sorting file path list - algorithm (javascript)
const pathList = ['/path1/abc', '/path1/123', '/path2/xyz', '/path2/0123', '/path3/123', '/path3/xyz','/path1/'];
const splittedArr = pathList.map(a => a.split('/'));
function sortPath(arr, index, start, end) {
arr.sort((a, b) => {
if (a < b) return -1;
if (a > b) return 1;
return 0;
});