Comparing version 1.2.0 to 1.2.1
@@ -30,2 +30,69 @@ (function(scope) { | ||
/** | ||
* add listener to observer | ||
* | ||
* @param name - event name | ||
* @param func - function | ||
* @param allListeners - listeners array | ||
* @param observer - observer object | ||
*/ | ||
this.addListener = function(name, func, allListeners, observer) { | ||
var listeners, obj, | ||
type = Util.getType(name); | ||
switch(type) { | ||
case 'string': | ||
listeners = allListeners[name]; | ||
if (!listeners) | ||
listeners = allListeners[name] = []; | ||
listeners.push(func); | ||
if (func && observer) | ||
observer.on(name, func); | ||
break; | ||
case 'object': | ||
obj = name; | ||
Object.keys(obj).forEach(function(name) { | ||
func = obj[name]; | ||
Util.addListener(name, func, allListeners, observer); | ||
}); | ||
break; | ||
} | ||
return this; | ||
}; | ||
/** | ||
* remove listener from observer | ||
* | ||
* @param name - event name | ||
* @param func - function | ||
* @param allListeners - listeners array | ||
* @param observer - observer object | ||
*/ | ||
this.removeListener = function(name, func, allListeners, observer) { | ||
var listeners; | ||
if (observer) | ||
observer.removeListener(name, func); | ||
listeners = allListeners[name]; | ||
if (listeners) | ||
listeners = listeners.map(function(listener) { | ||
if (listener === func) | ||
listener = null; | ||
return listener; | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Функция ищет в имени файла расширение | ||
@@ -48,3 +115,3 @@ * и если находит возвращает true | ||
regExp = new RegExp(regStr); | ||
regExp = new RegExp(regStr, 'i'); | ||
isMatch = name.match(regExp); | ||
@@ -51,0 +118,0 @@ |
{ | ||
"name": "util-io", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
@@ -5,0 +5,0 @@ "description": "Util.io - utilites for vanila js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36198
847