Skip to content

Instantly share code, notes, and snippets.

View tofusoup429's full-sized avatar

bongkow tofusoup429

View GitHub Profile
export declare const checkIfNoSameElementExistInArray: <T extends unknown>(_array: T[]) => boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkIfNoSameElementExistInArray = void 0;
var checkIfNoSameElementExistInArray = function (_array) {
//return false if any overlapped value exist.
//return true if no same element exists.
var arrayLen = _array.length;
var set = new Set(_array);
var setLen = set.size;
return arrayLen === setLen;
{
"name": "@tofusoup429/pubfuncs",
"version": "1.0.5",
"description": "collection of trivial functions",
"main": "dist/index.js",
"author": "tofusoup429",
"license": "MIT",
"scripts": {
"build": "rm -rf dist && tsc"
},
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"strict": true,
"downlevelIteration": true
},
"include": ["src"],
export const checkIfNoSameElementExistInArray = <T extends any>(_array:T[]):boolean => {
//return false if any overlapped value exist.
//return true if no same element exists.
let arrayLen:number = _array.length;
let set = new Set(_array);
let setLen = set.size;
return arrayLen === setLen
}
export * from './arrayMinusArray';
export * from './getSameKeyedValueFromObjectArray';
export * from './checkIfNoSameElementExistsInArray';
export * from './splitArray';
let cars = ["Toyota", "Hyundai", "BMW"]
for(let i = 0; i<cars.length; i++){
console.log(cars[i])
}
/**
Toyota
Hyundai
BMW
**/
let originalArray = [1,2,3,4,5,6];
let returnValue = originalArray.forEach((element, index, array)=>{
if(element%2) console.log(index, element, array);
})
console.log('returnValue', returnValue)
/**
0 1 [ 1, 2, 3, 4, 5, 6 ]
2 3 [ 1, 2, 3, 4, 5, 6 ]
let originalArray = [1,2,3,4,5,6];
originalArray.forEach((element, index, array)=>{
if(!element%2) console.log(index, element, array);
})
/**
0 1 [ 1, 2, 3, 4, 5, 6 ]
2 3 [ 1, 2, 3, 4, 5, 6 ]
4 5 [ 1, 2, 3, 4, 5, 6 ]
**/
let originalArray = [1,2,3,4,5,6];
originalArray.forEach((element, index)=>{
if(!element%2) console.log(index, element);
})
/**
0 1
2 3
4 5
**/