Skip to content

Instantly share code, notes, and snippets.

View manar007's full-sized avatar

Narek manar007

  • Armenia,Yerevan
View GitHub Profile
@manar007
manar007 / gulpfile.js
Created June 28, 2014 14:47
gulp file configuration example
/**
* Created by narek.mamikonyan on 6/26/2014.
*/
var config = {
srcDir: "src",
distDir: "dist",
tmpDir: ".tmp"
};
var runSequence = require('run-sequence');
@manar007
manar007 / Http.js
Last active February 11, 2020 06:24
Promises with vanilla js, helper http function
// Support: http://caniuse.com/promises
function Http () {
/**
* Helper for http calls
* @param method
* @param url
* @param data
* @returns {Promise}
*/
function makeRequest(method,url,data) {
@manar007
manar007 / Bind.js
Last active July 19, 2018 23:12
js bind simple implementation
Function.prototype.bind = function(context){
var that = this,
slicedArgs = Array.prototype.splice.call(arguments, 1),
bounded = function (){
var newArgs = slicedArgs.concat(Array.prototype.splice.call(arguments));
return that.apply(context,newArgs);
}
bounded.prototype = that.prototype;
return bounded;
};
@manar007
manar007 / watchersCount.js
Created August 14, 2014 20:27
count angular watchers
(function () {
var root = angular.element(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
@manar007
manar007 / getElementByClassName from particular element.js
Last active August 29, 2015 14:07
Find element inside another element with class
/**
* @description finds element by given classname inside the dom list of givent element
* NOTE its will return only one element
* @param element <HTMLElement>
* @param className <String>
* @returns {*} <HTMLElement>
*/
function getElementByClassName(element, className) {
var foundedElement;
@manar007
manar007 / sorted.js
Created April 4, 2015 11:49
Merge sorted arrays
function mergeArrays(a,b){
var output = [],j,i;
for(i = 0; i< a.length; i++){
output.push(a[i]);
for(j=0; j< b.length; j++){
if(b[j] <= a[i]){
output.push(b[j]);
b.splice(j,1);
}