Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Hossein Rahimi hrahimi270

🏠
Working from home
View GitHub Profile
@hrahimi270
hrahimi270 / validateCard.js
Created Jan 25, 2020 — forked from mahmoud-eskandari/validateCard.js
اعتبار سنجی کارت عابر بانک ایران در جاوا اسکریپت \ Validation function of Iranian bank cards in Javascript \ تابع تشخیص صحت کارت عابربانک
View validateCard.js
"use strict";
// By Mahmoud Eskandari @ MIT license
function validateCard(card) {
if (typeof card === 'undefined'
|| card === null
|| card.length !== 16) {
return false;
}
let cardTotal = 0;
for (let i = 0; i < 16; i += 1) {
@hrahimi270
hrahimi270 / eventemitter.js
Created Apr 10, 2020 — forked from mudge/eventemitter.js
A very simple EventEmitter in pure JavaScript (suitable for both node.js and browsers).
View eventemitter.js
/* Polyfill indexOf. */
var indexOf;
if (typeof Array.prototype.indexOf === 'function') {
indexOf = function (haystack, needle) {
return haystack.indexOf(needle);
};
} else {
indexOf = function (haystack, needle) {
var i = 0, length = haystack.length, idx = -1, found = false;