From d900549f9ec0e9b31a0ab3907edcc33bdfbb123e Mon Sep 17 00:00:00 2001 From: ahmedeldessouki Date: Sun, 14 Feb 2021 18:56:41 +0300 Subject: [PATCH 1/4] another Kata --- index.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index 4ea6312..9f80ffd 100644 --- a/index.js +++ b/index.js @@ -1,22 +1,19 @@ -function moveZeros(arr = '') { - function twistIt(str = '') { - return str.split('').map((a, i, arr) => arr[arr.length - i - 1]).join('') - } - return arr.split(' ').map(item => twistIt(item)).join(' ') -} - -console.log(moveZeros("double spaces"), "double spaces", '==>', "elbuod secaps") -console.log(moveZeros("double spaces"), "double spaces", '==>', "elbuod secaps") -console.log(moveZeros("double spaces"), "double spaces", '==>', "elbuod secaps") - -function manhattanDistance(arr0, arr1) { - function fn(params) { - return Math.abs(params) +function manhattanDistance(nFloors) { + const arr = [] + if (nFloors < 0) return arr + for (let i = 0; i < nFloors; i++) { + let str = '*' + str = str.padStart(nFloors - i, ' ') + for (let x = 0; x < i; x++) { + str += '**' + } + str = str.padEnd(nFloors * 2 - 1, ' ') + arr.push(str) } - return (fn(arr0[0] - arr1[0]) + fn(arr0[1] - arr1[1])) + return arr } -console.log(manhattanDistance([1, 1], [1, 1]), '=> returns 0') -console.log(manhattanDistance([5, 4], [3, 2]), '=> returns 4') -console.log(manhattanDistance([1, 1], [0, 3]), '=> returns 3') +console.log(manhattanDistance(1 + 1)) +console.log(manhattanDistance(4 + 2)) +console.log(manhattanDistance(1 + 3)) From e9fb413f811921e2b55430e37863080176f646a2 Mon Sep 17 00:00:00 2001 From: ahmedeldessouki Date: Sun, 14 Feb 2021 20:11:04 +0300 Subject: [PATCH 2/4] kata --- indexTs.js | 7 +++++ indexTs.ts | 9 +++++++ tsconfig.json | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 indexTs.js create mode 100644 indexTs.ts create mode 100644 tsconfig.json diff --git a/indexTs.js b/indexTs.js new file mode 100644 index 0000000..b662df3 --- /dev/null +++ b/indexTs.js @@ -0,0 +1,7 @@ +"use strict"; +function manhattanDistance(nFloors) { + return parseInt(nFloors.toString().split('').sort(function (a, b) { return parseInt(a) - parseInt(b); }).reverse().join('')); +} +console.log(manhattanDistance(42145)); +console.log(manhattanDistance(145263)); +console.log(manhattanDistance(123456789)); diff --git a/indexTs.ts b/indexTs.ts new file mode 100644 index 0000000..99c16f6 --- /dev/null +++ b/indexTs.ts @@ -0,0 +1,9 @@ + +function manhattanDistance(nFloors: number): number { + return parseInt(nFloors.toString().split('').sort((a,b)=> parseInt(a)-parseInt(b)).reverse().join('')) + +} + +console.log(manhattanDistance(42145 )) +console.log(manhattanDistance(145263 )) +console.log(manhattanDistance(123456789 )) diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4c96f69 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,73 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + + /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ + "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, + "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, + "lib": [ + "ESNext", + "DOM" + ] /* Specify library files to be included in the compilation. */, + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */, + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + + /* Advanced Options */ + "skipLibCheck": true /* Skip type checking of declaration files. */, + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + } +} From a9394a5aed490fd8b78097a0ba11a5c898ffdd62 Mon Sep 17 00:00:00 2001 From: ahmedeldessouki Date: Wed, 17 Feb 2021 13:58:39 +0300 Subject: [PATCH 3/4] Higher Order Function --- .eslintrc.js | 17 ++- index.js | 75 +++++++++--- indexTs.ts | 8 +- package-lock.json | 294 +++++++++++++++++++++++++++++++--------------- package.json | 8 +- 5 files changed, 277 insertions(+), 125 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5f54645..3174cc6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,20 +1,25 @@ module.exports = { env: { browser: true, - es2021: true + es2021: true, }, extends: [ - 'standard', + 'airbnb-base', 'prettier/recommended' ], parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 12, - sourceType: 'module' + sourceType: 'module', }, plugins: [ - '@typescript-eslint' + '@typescript-eslint', ], rules: { - } -} + 'no-console': 0, + 'no-undef': 1, + 'no-unused-vars': 1, + 'no-return-assign': 0, + 'no-param-reassign': 0, + }, +}; diff --git a/index.js b/index.js index 9f80ffd..ac4888a 100644 --- a/index.js +++ b/index.js @@ -1,19 +1,64 @@ +const chalk = require('chalk'); +const arr = [ + ['1536', '1541'], + ['1542', '1548'], + ['1549', '1563'], + ['1564', '1565'], + ['1566', '1567'], + ['1568', '1600'], + ['1601', '1611', '1611'], + ['126523', '126524'], + ['126530', '126531'], + ['126535', '126536'], +]; -function manhattanDistance(nFloors) { - const arr = [] - if (nFloors < 0) return arr - for (let i = 0; i < nFloors; i++) { - let str = '*' - str = str.padStart(nFloors - i, ' ') - for (let x = 0; x < i; x++) { - str += '**' - } - str = str.padEnd(nFloors * 2 - 1, ' ') - arr.push(str) +function flattening(thatArr) { + if (!Array.isArray(thatArr)) { + return thatArr; } - return arr + const x = thatArr.reduce((a, b) => a.concat(b)); + return flattening(x); +} + +console.log(flattening(arr)); + +function yourOwnLoop(value, testFunction, updateFunction) { + return (bodyFunction) => { + let x; + for (let index = value; testFunction(index); index = updateFunction(index)) { + x = bodyFunction(index); + if (!x) { + return x + } + } + return x + }; } +const loopsTenTimesAndIncrementBy1 = yourOwnLoop(10, (i) => i < 20, (n) => { + return n + 1; +}); -console.log(manhattanDistance(1 + 1)) -console.log(manhattanDistance(4 + 2)) -console.log(manhattanDistance(1 + 3)) +loopsTenTimesAndIncrementBy1((number) => { + return number; +}) + +// ======== Array.Every ======== + +const arrayEvery = (arrr, predicate) => { + const arrayLooping = yourOwnLoop(0, (i, max = arrr.length) => i < max, (n) => { + return n + 1; + }); + let result = arrayLooping((i, arrX = arr) => { + let x = predicate(arrX[i]) + return x + }) + + return result + +} +console.log(chalk.bgBlue(chalk.black('[Array.Every] ', arr.length, arr[0].length))) +console.log(chalk.bgRedBright(chalk.black('[Array.Every]: Should Fail', arrayEvery(arr, item => item.length < 3)))) +console.log(chalk.bgGreenBright(chalk.black('[Array.Every]: Should Pass', arrayEvery(arr, item => item.length < 4)))) +console.log(chalk.bgRedBright(chalk.black('[Array.Every]: Should Fail', arr.every(item => item.length < 3)))) +console.log(chalk.bgGreenBright(chalk.black('[Array.Every]: Should Pass', arr.every(item => item.length < 4)))) +console.log(chalk.bgGreenBright(chalk.black('[Array.Some]: Should Pass', arr.some(item => item.length > 2)))) \ No newline at end of file diff --git a/indexTs.ts b/indexTs.ts index 99c16f6..8aeb63f 100644 --- a/indexTs.ts +++ b/indexTs.ts @@ -1,9 +1,9 @@ function manhattanDistance(nFloors: number): number { - return parseInt(nFloors.toString().split('').sort((a,b)=> parseInt(a)-parseInt(b)).reverse().join('')) + return parseInt(nFloors.toString().split('').sort((a, b) => parseInt(a) - parseInt(b)).reverse().join('')) } -console.log(manhattanDistance(42145 )) -console.log(manhattanDistance(145263 )) -console.log(manhattanDistance(123456789 )) +console.log(manhattanDistance(42145)) +console.log(manhattanDistance(145263)) +console.log(manhattanDistance(123456789)) diff --git a/package-lock.json b/package-lock.json index 503e88f..8d73c7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,9 +8,11 @@ "prettier": "^2.2.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^4.14.1", - "@typescript-eslint/parser": "^4.14.1", - "eslint": "^7.19.0", + "@typescript-eslint/eslint-plugin": "^4.15.1", + "@typescript-eslint/parser": "^4.15.1", + "chalk": "^4.1.0", + "eslint": "^7.20.0", + "eslint-config-airbnb-base": "^14.2.1", "eslint-config-standard": "^16.0.2", "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", @@ -174,13 +176,13 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.1.tgz", - "integrity": "sha512-5JriGbYhtqMS1kRcZTQxndz1lKMwwEXKbwZbkUZNnp6MJX0+OVXnG0kOlBZP4LUAxEyzu3cs+EXd/97MJXsGfw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.1.tgz", + "integrity": "sha512-yW2epMYZSpNJXZy22Biu+fLdTG8Mn6b22kR3TqblVk50HGNV8Zya15WAXuQCr8tKw4Qf1BL4QtI6kv6PCkLoJw==", "dev": true, "dependencies": { - "@typescript-eslint/experimental-utils": "4.14.1", - "@typescript-eslint/scope-manager": "4.14.1", + "@typescript-eslint/experimental-utils": "4.15.1", + "@typescript-eslint/scope-manager": "4.15.1", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "lodash": "^4.17.15", @@ -206,15 +208,15 @@ } }, "node_modules/@typescript-eslint/experimental-utils": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.1.tgz", - "integrity": "sha512-2CuHWOJwvpw0LofbyG5gvYjEyoJeSvVH2PnfUQSn0KQr4v8Dql2pr43ohmx4fdPQ/eVoTSFjTi/bsGEXl/zUUQ==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.15.1.tgz", + "integrity": "sha512-9LQRmOzBRI1iOdJorr4jEnQhadxK4c9R2aEAsm7WE/7dq8wkKD1suaV0S/JucTL8QlYUPU1y2yjqg+aGC0IQBQ==", "dev": true, "dependencies": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.14.1", - "@typescript-eslint/types": "4.14.1", - "@typescript-eslint/typescript-estree": "4.14.1", + "@typescript-eslint/scope-manager": "4.15.1", + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/typescript-estree": "4.15.1", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" }, @@ -230,14 +232,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.14.1.tgz", - "integrity": "sha512-mL3+gU18g9JPsHZuKMZ8Z0Ss9YP1S5xYZ7n68Z98GnPq02pYNQuRXL85b9GYhl6jpdvUc45Km7hAl71vybjUmw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.15.1.tgz", + "integrity": "sha512-V8eXYxNJ9QmXi5ETDguB7O9diAXlIyS+e3xzLoP/oVE4WCAjssxLIa0mqCLsCGXulYJUfT+GV70Jv1vHsdKwtA==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "4.14.1", - "@typescript-eslint/types": "4.14.1", - "@typescript-eslint/typescript-estree": "4.14.1", + "@typescript-eslint/scope-manager": "4.15.1", + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/typescript-estree": "4.15.1", "debug": "^4.1.1" }, "engines": { @@ -257,13 +259,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.14.1.tgz", - "integrity": "sha512-F4bjJcSqXqHnC9JGUlnqSa3fC2YH5zTtmACS1Hk+WX/nFB0guuynVK5ev35D4XZbdKjulXBAQMyRr216kmxghw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.15.1.tgz", + "integrity": "sha512-ibQrTFcAm7yG4C1iwpIYK7vDnFg+fKaZVfvyOm3sNsGAerKfwPVFtYft5EbjzByDJ4dj1WD8/34REJfw/9wdVA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "4.14.1", - "@typescript-eslint/visitor-keys": "4.14.1" + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/visitor-keys": "4.15.1" }, "engines": { "node": "^8.10.0 || ^10.13.0 || >=11.10.1" @@ -274,9 +276,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.14.1.tgz", - "integrity": "sha512-SkhzHdI/AllAgQSxXM89XwS1Tkic7csPdndUuTKabEwRcEfR8uQ/iPA3Dgio1rqsV3jtqZhY0QQni8rLswJM2w==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.15.1.tgz", + "integrity": "sha512-iGsaUyWFyLz0mHfXhX4zO6P7O3sExQpBJ2dgXB0G5g/8PRVfBBsmQIc3r83ranEQTALLR3Vko/fnCIVqmH+mPw==", "dev": true, "engines": { "node": "^8.10.0 || ^10.13.0 || >=11.10.1" @@ -287,17 +289,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.1.tgz", - "integrity": "sha512-M8+7MbzKC1PvJIA8kR2sSBnex8bsR5auatLCnVlNTJczmJgqRn8M+sAlQfkEq7M4IY3WmaNJ+LJjPVRrREVSHQ==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.1.tgz", + "integrity": "sha512-z8MN3CicTEumrWAEB2e2CcoZa3KP9+SMYLIA2aM49XW3cWIaiVSOAGq30ffR5XHxRirqE90fgLw3e6WmNx5uNw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "4.14.1", - "@typescript-eslint/visitor-keys": "4.14.1", + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/visitor-keys": "4.15.1", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", - "lodash": "^4.17.15", "semver": "^7.3.2", "tsutils": "^3.17.1" }, @@ -315,12 +316,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.1.tgz", - "integrity": "sha512-TAblbDXOI7bd0C/9PE1G+AFo7R5uc+ty1ArDoxmrC1ah61Hn6shURKy7gLdRb1qKJmjHkqu5Oq+e4Kt0jwf1IA==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.1.tgz", + "integrity": "sha512-tYzaTP9plooRJY8eNlpAewTOqtWW/4ff/5wBjNVaJ0S0wC4Gpq/zDVRTJa5bq2v1pCNQ08xxMCndcvR+h7lMww==", "dev": true, "dependencies": { - "@typescript-eslint/types": "4.14.1", + "@typescript-eslint/types": "4.15.1", "eslint-visitor-keys": "^2.0.0" }, "engines": { @@ -554,6 +555,12 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "node_modules/confusing-browser-globals": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.10.tgz", + "integrity": "sha512-gNld/3lySHwuhaVluJUKLePYirM3QNCKzVxqAdhJII9/WXKVX5PURzMVJspS1jTslSqjeuG4KMVTSouit5YPHA==", + "dev": true + }, "node_modules/contains-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", @@ -718,12 +725,12 @@ } }, "node_modules/eslint": { - "version": "7.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.19.0.tgz", - "integrity": "sha512-CGlMgJY56JZ9ZSYhJuhow61lMPPjUzWmChFya71Z/jilVos7mR/jPgaEfVGgMBY5DshbKdG8Ezb8FDCHcoMEMg==", + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.20.0.tgz", + "integrity": "sha512-qGi0CTcOGP2OtCQBgWZlQjcTuP0XkIpYFj25XtRTQSHC+umNnp7UMshr2G8SLsRFYDdAPFeHOsiteadmMH02Yw==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.0.0", + "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.3.0", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -735,7 +742,7 @@ "eslint-utils": "^2.1.0", "eslint-visitor-keys": "^2.0.0", "espree": "^7.3.1", - "esquery": "^1.2.0", + "esquery": "^1.4.0", "esutils": "^2.0.2", "file-entry-cache": "^6.0.0", "functional-red-black-tree": "^1.0.1", @@ -771,6 +778,24 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-config-airbnb-base": { + "version": "14.2.1", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.1.tgz", + "integrity": "sha512-GOrQyDtVEc1Xy20U7vsB2yAoB4nBlfH5HZJeatRXHleO+OS5Ot+MWij4Dpltw4/DyIkqUfqz1epfhVR5XWWQPA==", + "dev": true, + "dependencies": { + "confusing-browser-globals": "^1.0.10", + "object.assign": "^4.1.2", + "object.entries": "^1.1.2" + }, + "engines": { + "node": ">= 6" + }, + "peerDependencies": { + "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", + "eslint-plugin-import": "^2.22.1" + } + }, "node_modules/eslint-config-standard": { "version": "16.0.2", "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-16.0.2.tgz", @@ -1054,9 +1079,9 @@ } }, "node_modules/esquery": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", - "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "dependencies": { "estraverse": "^5.1.0" @@ -1773,6 +1798,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/object.entries": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.3.tgz", + "integrity": "sha512-ym7h7OZebNS96hn5IJeyUmaWhaSM4SVtAPPfNLQEI2MYWCO2egsITb9nab2+i/Pwibx+R0mtn+ltKJXRSeTMGg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "es-abstract": "^1.18.0-next.1", + "has": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/object.values": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.2.tgz", @@ -1987,6 +2027,26 @@ "node": ">=6" } }, + "node_modules/queue-microtask": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.2.tgz", + "integrity": "sha512-dB15eXv3p2jDlbOiNLyMabYg1/sXvppd8DP2J3EOCQ0AkuSXCW2tP7mnVouVLJKgUMY6yP0kcQDVpLCN13h4Xg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -2095,9 +2155,9 @@ } }, "node_modules/run-parallel": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz", - "integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, "funding": [ { @@ -2112,7 +2172,10 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } }, "node_modules/semver": { "version": "7.3.4", @@ -2620,13 +2683,13 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.1.tgz", - "integrity": "sha512-5JriGbYhtqMS1kRcZTQxndz1lKMwwEXKbwZbkUZNnp6MJX0+OVXnG0kOlBZP4LUAxEyzu3cs+EXd/97MJXsGfw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.1.tgz", + "integrity": "sha512-yW2epMYZSpNJXZy22Biu+fLdTG8Mn6b22kR3TqblVk50HGNV8Zya15WAXuQCr8tKw4Qf1BL4QtI6kv6PCkLoJw==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.14.1", - "@typescript-eslint/scope-manager": "4.14.1", + "@typescript-eslint/experimental-utils": "4.15.1", + "@typescript-eslint/scope-manager": "4.15.1", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "lodash": "^4.17.15", @@ -2636,70 +2699,69 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.1.tgz", - "integrity": "sha512-2CuHWOJwvpw0LofbyG5gvYjEyoJeSvVH2PnfUQSn0KQr4v8Dql2pr43ohmx4fdPQ/eVoTSFjTi/bsGEXl/zUUQ==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.15.1.tgz", + "integrity": "sha512-9LQRmOzBRI1iOdJorr4jEnQhadxK4c9R2aEAsm7WE/7dq8wkKD1suaV0S/JucTL8QlYUPU1y2yjqg+aGC0IQBQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.14.1", - "@typescript-eslint/types": "4.14.1", - "@typescript-eslint/typescript-estree": "4.14.1", + "@typescript-eslint/scope-manager": "4.15.1", + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/typescript-estree": "4.15.1", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.14.1.tgz", - "integrity": "sha512-mL3+gU18g9JPsHZuKMZ8Z0Ss9YP1S5xYZ7n68Z98GnPq02pYNQuRXL85b9GYhl6jpdvUc45Km7hAl71vybjUmw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.15.1.tgz", + "integrity": "sha512-V8eXYxNJ9QmXi5ETDguB7O9diAXlIyS+e3xzLoP/oVE4WCAjssxLIa0mqCLsCGXulYJUfT+GV70Jv1vHsdKwtA==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.14.1", - "@typescript-eslint/types": "4.14.1", - "@typescript-eslint/typescript-estree": "4.14.1", + "@typescript-eslint/scope-manager": "4.15.1", + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/typescript-estree": "4.15.1", "debug": "^4.1.1" } }, "@typescript-eslint/scope-manager": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.14.1.tgz", - "integrity": "sha512-F4bjJcSqXqHnC9JGUlnqSa3fC2YH5zTtmACS1Hk+WX/nFB0guuynVK5ev35D4XZbdKjulXBAQMyRr216kmxghw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.15.1.tgz", + "integrity": "sha512-ibQrTFcAm7yG4C1iwpIYK7vDnFg+fKaZVfvyOm3sNsGAerKfwPVFtYft5EbjzByDJ4dj1WD8/34REJfw/9wdVA==", "dev": true, "requires": { - "@typescript-eslint/types": "4.14.1", - "@typescript-eslint/visitor-keys": "4.14.1" + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/visitor-keys": "4.15.1" } }, "@typescript-eslint/types": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.14.1.tgz", - "integrity": "sha512-SkhzHdI/AllAgQSxXM89XwS1Tkic7csPdndUuTKabEwRcEfR8uQ/iPA3Dgio1rqsV3jtqZhY0QQni8rLswJM2w==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.15.1.tgz", + "integrity": "sha512-iGsaUyWFyLz0mHfXhX4zO6P7O3sExQpBJ2dgXB0G5g/8PRVfBBsmQIc3r83ranEQTALLR3Vko/fnCIVqmH+mPw==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.1.tgz", - "integrity": "sha512-M8+7MbzKC1PvJIA8kR2sSBnex8bsR5auatLCnVlNTJczmJgqRn8M+sAlQfkEq7M4IY3WmaNJ+LJjPVRrREVSHQ==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.1.tgz", + "integrity": "sha512-z8MN3CicTEumrWAEB2e2CcoZa3KP9+SMYLIA2aM49XW3cWIaiVSOAGq30ffR5XHxRirqE90fgLw3e6WmNx5uNw==", "dev": true, "requires": { - "@typescript-eslint/types": "4.14.1", - "@typescript-eslint/visitor-keys": "4.14.1", + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/visitor-keys": "4.15.1", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", - "lodash": "^4.17.15", "semver": "^7.3.2", "tsutils": "^3.17.1" } }, "@typescript-eslint/visitor-keys": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.1.tgz", - "integrity": "sha512-TAblbDXOI7bd0C/9PE1G+AFo7R5uc+ty1ArDoxmrC1ah61Hn6shURKy7gLdRb1qKJmjHkqu5Oq+e4Kt0jwf1IA==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.1.tgz", + "integrity": "sha512-tYzaTP9plooRJY8eNlpAewTOqtWW/4ff/5wBjNVaJ0S0wC4Gpq/zDVRTJa5bq2v1pCNQ08xxMCndcvR+h7lMww==", "dev": true, "requires": { - "@typescript-eslint/types": "4.14.1", + "@typescript-eslint/types": "4.15.1", "eslint-visitor-keys": "^2.0.0" } }, @@ -2866,6 +2928,12 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "confusing-browser-globals": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.10.tgz", + "integrity": "sha512-gNld/3lySHwuhaVluJUKLePYirM3QNCKzVxqAdhJII9/WXKVX5PURzMVJspS1jTslSqjeuG4KMVTSouit5YPHA==", + "dev": true + }, "contains-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", @@ -2989,12 +3057,12 @@ "dev": true }, "eslint": { - "version": "7.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.19.0.tgz", - "integrity": "sha512-CGlMgJY56JZ9ZSYhJuhow61lMPPjUzWmChFya71Z/jilVos7mR/jPgaEfVGgMBY5DshbKdG8Ezb8FDCHcoMEMg==", + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.20.0.tgz", + "integrity": "sha512-qGi0CTcOGP2OtCQBgWZlQjcTuP0XkIpYFj25XtRTQSHC+umNnp7UMshr2G8SLsRFYDdAPFeHOsiteadmMH02Yw==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", + "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.3.0", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -3006,7 +3074,7 @@ "eslint-utils": "^2.1.0", "eslint-visitor-keys": "^2.0.0", "espree": "^7.3.1", - "esquery": "^1.2.0", + "esquery": "^1.4.0", "esutils": "^2.0.2", "file-entry-cache": "^6.0.0", "functional-red-black-tree": "^1.0.1", @@ -3033,6 +3101,17 @@ "v8-compile-cache": "^2.0.3" } }, + "eslint-config-airbnb-base": { + "version": "14.2.1", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.1.tgz", + "integrity": "sha512-GOrQyDtVEc1Xy20U7vsB2yAoB4nBlfH5HZJeatRXHleO+OS5Ot+MWij4Dpltw4/DyIkqUfqz1epfhVR5XWWQPA==", + "dev": true, + "requires": { + "confusing-browser-globals": "^1.0.10", + "object.assign": "^4.1.2", + "object.entries": "^1.1.2" + } + }, "eslint-config-standard": { "version": "16.0.2", "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-16.0.2.tgz", @@ -3245,9 +3324,9 @@ "dev": true }, "esquery": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", - "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -3795,6 +3874,18 @@ "object-keys": "^1.1.1" } }, + "object.entries": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.3.tgz", + "integrity": "sha512-ym7h7OZebNS96hn5IJeyUmaWhaSM4SVtAPPfNLQEI2MYWCO2egsITb9nab2+i/Pwibx+R0mtn+ltKJXRSeTMGg==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "es-abstract": "^1.18.0-next.1", + "has": "^1.0.3" + } + }, "object.values": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.2.tgz", @@ -3946,6 +4037,12 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "queue-microtask": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.2.tgz", + "integrity": "sha512-dB15eXv3p2jDlbOiNLyMabYg1/sXvppd8DP2J3EOCQ0AkuSXCW2tP7mnVouVLJKgUMY6yP0kcQDVpLCN13h4Xg==", + "dev": true + }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -4022,10 +4119,13 @@ } }, "run-parallel": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz", - "integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==", - "dev": true + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "requires": { + "queue-microtask": "^1.2.2" + } }, "semver": { "version": "7.3.4", diff --git a/package.json b/package.json index ef2c5db..d43f5c9 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,11 @@ "prettier": "^2.2.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^4.14.1", - "@typescript-eslint/parser": "^4.14.1", - "eslint": "^7.19.0", + "@typescript-eslint/eslint-plugin": "^4.15.1", + "@typescript-eslint/parser": "^4.15.1", + "chalk": "^4.1.0", + "eslint": "^7.20.0", + "eslint-config-airbnb-base": "^14.2.1", "eslint-config-standard": "^16.0.2", "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", From a4fcb5bc52abbc9d11ba052186ae162cc1b670f3 Mon Sep 17 00:00:00 2001 From: ahmedeldessouki Date: Wed, 17 Feb 2021 14:02:20 +0300 Subject: [PATCH 4/4] ...: --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index ac4888a..4adc424 100644 --- a/index.js +++ b/index.js @@ -56,9 +56,9 @@ const arrayEvery = (arrr, predicate) => { return result } -console.log(chalk.bgBlue(chalk.black('[Array.Every] ', arr.length, arr[0].length))) -console.log(chalk.bgRedBright(chalk.black('[Array.Every]: Should Fail', arrayEvery(arr, item => item.length < 3)))) -console.log(chalk.bgGreenBright(chalk.black('[Array.Every]: Should Pass', arrayEvery(arr, item => item.length < 4)))) -console.log(chalk.bgRedBright(chalk.black('[Array.Every]: Should Fail', arr.every(item => item.length < 3)))) -console.log(chalk.bgGreenBright(chalk.black('[Array.Every]: Should Pass', arr.every(item => item.length < 4)))) -console.log(chalk.bgGreenBright(chalk.black('[Array.Some]: Should Pass', arr.some(item => item.length > 2)))) \ No newline at end of file +console.log(chalk.bgBlue.black('[Array.Every] ', arr.length, arr[0].length)) +console.log(chalk.bgRedBright.black('[Array.Every]: Should Fail', arrayEvery(arr, item => item.length < 3))) +console.log(chalk.bgGreenBright.black('[Array.Every]: Should Pass', arrayEvery(arr, item => item.length < 4))) +console.log(chalk.bgRedBright.black('[Array.Every]: Should Fail', arr.every(item => item.length < 3))) +console.log(chalk.bgGreenBright.black('[Array.Every]: Should Pass', arr.every(item => item.length < 4))) +console.log(chalk.bgGreenBright.black('[Array.Some]: Should Pass', arr.some(item => item.length > 2))) \ No newline at end of file