Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

this

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

this - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

build/debug/this_debug_0.1.5.js

29

build/debug/this_debug_0.1.4.js

@@ -1,4 +0,31 @@

/*! this - v0.1.4 - 2013-02-20 - Author: Ricky Clegg || me@rickyclegg.com */
/*! this - v0.1.4 - 2013-02-21 - Author: Ricky Clegg || me@rickyclegg.com */
(function () {
if (!Array.prototype.indexOf) {
/**
* Returns the first index at which a given element can be found in the array, or -1 if it is not present.
* @param searchElement {Object} Element to locate in the array.
* @param fromIndex {int} The index at which to begin the search. Defaults to 0,
* i.e. the whole array will be searched. If the index is greater than or equal to the length of the array,
* -1 is returned, i.e. the array will not be searched. If negative,
* it is taken as the offset from the end of the array.
* Note that even when the index is negative, the array is still searched from front to back.
* If the calculated index is less than 0, the whole array will be searched.
* @returns {Number}
* @memberOf Array.prototype
*/
Array.prototype.indexOf = function (searchElement, fromIndex) {
var i, numberOfItems = this.length;
for (i = (fromIndex || 0); i < numberOfItems; i += 1) {
if (this[i] === searchElement) {
return i;
}
}
return -1;
};
}
}());
(function () {
/**

@@ -5,0 +32,0 @@ * Extends all methods and properties from the parsed Object.

4

build/production/this_0.1.4.js

@@ -1,2 +0,2 @@

/*! this - v0.1.4 - 2013-02-20 - Author: Ricky Clegg || me@rickyclegg.com */
(function(){Function.prototype.extend=function(e){return typeof e.constructor=="function"?(this.prototype=new e,this.prototype.constructor=this):(this.prototype=e,this.prototype.constructor=this),this},Function.prototype.bind||function(){var e=Array.prototype.slice;Function.prototype.bind=function(t){var n=this,r;return arguments.length>1?(r=e.call(arguments,1),function(){var i=r;return arguments.length>0&&(i=r.concat(e.call(arguments))),n.apply(t,i)}):function(){return arguments.length>0?n.apply(t,arguments):n.call(t)}}}(),Function.prototype.memoize=function(){var e={},t=this,n=Array.prototype.join;return function(){var r=n.call(arguments);return e[r]||(e[r]=t.apply(this,arguments)),e[r]}}})();var e=function(){function e(){this._eventObjects=[]}function t(e,t){return e===t}function n(t,n){var r=t&&n,i=typeof t=="string",s=typeof n=="function";if(!s)throw new TypeError(e.TYPE_ERROR);return r&&i&&s}function r(e,n,r){var i,s=e.length;for(i=0;i<s;i+=1)if(t(e[i].type,n)&&t(e[i].callback,r))return e[i];return null}function i(e,n){var r,i=e.length;for(r=0;r<i;r+=1)if(t(e[r].type,n))return!!e[r];return!1}return e.TYPE_ERROR="The listener specified is not a function.",e.prototype.addEventListener=function(e,t,i){return!n(e,t)||r(this._eventObjects,e,t)?!1:(this._eventObjects.push({"type":e,"callback":t,"listenerScope":i}),!0)},e.prototype.dispatchEvent=function(e){var n,r=this._eventObjects.length,i=!1;for(n=0;n<r;n+=1)t(this._eventObjects[n].type,e.type)&&(e.target=this,this._eventObjects[n].callback.apply(this._eventObjects[n].listenerScope,[e]),i=!0);return i},e.prototype.hasEventListener=function(e){return i(this._eventObjects,e)},e.prototype.removeEventListener=function(e,t){var i;this.hasEventListener(e)&&n(e,t)&&(i=r(this._eventObjects,e,t),this._eventObjects.splice(this._eventObjects.indexOf(i),1))},e}();
/*! this - v0.1.4 - 2013-02-21 - Author: Ricky Clegg || me@rickyclegg.com */
(function(){Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var n,r=this.length;for(n=t||0;n<r;n+=1)if(this[n]===e)return n;return-1})})(),function(){Function.prototype.extend=function(e){return typeof e.constructor=="function"?(this.prototype=new e,this.prototype.constructor=this):(this.prototype=e,this.prototype.constructor=this),this},Function.prototype.bind||function(){var e=Array.prototype.slice;Function.prototype.bind=function(t){var n=this,r;return arguments.length>1?(r=e.call(arguments,1),function(){var i=r;return arguments.length>0&&(i=r.concat(e.call(arguments))),n.apply(t,i)}):function(){return arguments.length>0?n.apply(t,arguments):n.call(t)}}}(),Function.prototype.memoize=function(){var e={},t=this,n=Array.prototype.join;return function(){var r=n.call(arguments);return e[r]||(e[r]=t.apply(this,arguments)),e[r]}}}();var e=function(){function e(){this._eventObjects=[]}function t(e,t){return e===t}function n(t,n){var r=t&&n,i=typeof t=="string",s=typeof n=="function";if(!s)throw new TypeError(e.TYPE_ERROR);return r&&i&&s}function r(e,n,r){var i,s=e.length;for(i=0;i<s;i+=1)if(t(e[i].type,n)&&t(e[i].callback,r))return e[i];return null}function i(e,n){var r,i=e.length;for(r=0;r<i;r+=1)if(t(e[r].type,n))return!!e[r];return!1}return e.TYPE_ERROR="The listener specified is not a function.",e.prototype.addEventListener=function(e,t,i){return!n(e,t)||r(this._eventObjects,e,t)?!1:(this._eventObjects.push({"type":e,"callback":t,"listenerScope":i}),!0)},e.prototype.dispatchEvent=function(e){var n,r=this._eventObjects.length,i=!1;for(n=0;n<r;n+=1)t(this._eventObjects[n].type,e.type)&&(e.target=this,this._eventObjects[n].callback.apply(this._eventObjects[n].listenerScope,[e]),i=!0);return i},e.prototype.hasEventListener=function(e){return i(this._eventObjects,e)},e.prototype.removeEventListener=function(e,t){var i;this.hasEventListener(e)&&n(e,t)&&(i=r(this._eventObjects,e,t),this._eventObjects.splice(this._eventObjects.indexOf(i),1))},e}();

@@ -12,2 +12,4 @@ // This

//
// We have tried to not repeat other libraries. I have not made any utilities as you can use great libraries like [Underscore](http://underscorejs.org/).
//
// What we are preaching is nothing new. I suggest that you go check out [Clean Coders](http://www.cleancoders.com/) by Uncle Bob.

@@ -98,2 +100,3 @@

// ####Closure example:
// Account class.

@@ -196,3 +199,113 @@ var Account = (function () {

// Events
// -----------
// this creates a global EventDispatcher class for native style events.
// ###EventDispatcher
var eventDispatcher = new EventDispatcher();
// Normally you will not create new instances of EventDispatcher. The classes main purpose is to be extended to give you modules event based functionality.
var Work = (function () {
function Work() {}
// Adds event functionality to the Work class.
Work.extend(EventDispatcher);
// Adds any public function SuperHero needs.
Work.prototype.addEmployee = function (employee) {
/* Add an employee */
this.dispatchEvent({type: 'added', employee: employee});
};
return Work;
}());
//
//
// ###addEventListener
// Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
// If you no longer need an event listener, remove it by calling removeEventListener(), or memory problems could result.
//
// * param | **eventType: String** | The type of event.
// * param | **listener: Function** | listener The listener function that processes the event. This function must accept an Event object as its only parameter and should return nothing.
// * param | **listenerScope: Object** | The scope you want the listener function to be called with.
// * returns | **Boolean** | Returns true if event is added.
EventDispatcher.prototype.addEventListener(eventType: String, listener: Function, listenerScope: Object): Boolean
// ####Example:
eventDispatcher.addEventListener('complete', function () {}, this);
//
//
// ###dispatchEvent
// Dispatches an event into the event flow.
// The event target is the EventDispatcher object upon which the dispatchEvent() method is called.
//
// * param | **event: Object** | The Event object that is dispatched into the event flow.
// * returns | **Boolean** | A value of true if the event was successfully dispatched.
EventDispatcher.prototype.dispatchEvent(event: Object): Boolean
// ####Example:
eventDispatcher.dispatchEvent({
type: 'added',
data: [1, 2, 3]
});
//
//
// ###hasEventListener
// Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
//
// * param | **eventType: String** | The type of event.
// * returns | **Boolean** | A value of true if the class is managing an event of that type.
EventDispatcher.prototype.hasEventListener(eventType: String): Boolean
// ####Example:
if (!eventDispatcher.hasEventListener('added')) {
eventDispatcher.addEventListener('added', function () {}, this);
}
//
//
// ###removeEventListener
// Removes a listener from the EventDispatcher object. If there is no matching listener registered with the EventDispatcher object, a call to this method has no effect.
//
// * param | **eventType: String** | The type of event.
// * param | **listener: Function** | The listener object to remove.
// * throws | **TypeError** | The listener specified is not a function.
EventDispatcher.prototype.removeEventListener(eventType: String, listener: Function)
// ####Example:
function addedHandler(event) {
/* Some code */
}
eventDispatcher.removeEventListener('added', addedHandler);
//
//
// **IMPORTANT -
// Event listeners can easily create memory leaks if you do not clean up your code.
// Be sure to use removeEventListener once your event is no longer needed.**
//
//
//
// ###Event Objects
//
// This can be as simple as a basic object, extend the native JavaScript event or create your own class.
// It does not mater which you use. The only property your object requires is 'type'.
//
//
// ####Example:
var basicEvent = {
type: 'added'
};
var nativeEvent = new Event('added');
var myApp.events.Event = function (type) {
this.type = type;
};
// License

@@ -203,2 +316,2 @@ // -------

//
//Licensed under the APACHE license.
//Licensed under the MIT license.
{
"name": "this",
"description": "A tiny library for writing OO JavaScript. A JavaScript library that tries its best not to be a library. Rules are being broken but this just does not care. This adds functionality to globals already in JavaScript (Often frowned upon). But I'm all about not choosing a big library until the project needs it.",
"version": "0.1.4",
"version": "0.1.5",
"homepage": "https://github.com/rickyclegg/this",

@@ -21,6 +21,6 @@ "author": {

"type": "APACHE",
"url": "https://github.com/rickyclegg/this/issues/blob/master/LICENSE-APACHE"
"url": "https://github.com/rickyclegg/this/issues/blob/master/LICENSE-MIT"
}
],
"main": "grunt.js",
"main": "Gruntfile.js",
"bin": "bin/this",

@@ -31,4 +31,7 @@ "engines": {

"devDependencies": {
"grunt": "~0.3.17",
"grunt-html": "~0.3.1"
"grunt": "~0.4.0",
"grunt-contrib-watch": "~0.2.0",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-uglify": "~0.1.1"
},

@@ -35,0 +38,0 @@ "keywords": [

@@ -110,7 +110,8 @@ # this

## Release History
* 2012/14/2 - v0.1.4 - Updated API, added EventDispatcher but not yet tested.
* 2012/25/2 - v0.1.5 - Added tests for EventDispatcher. Added Array.indexOf. Updated API.
* 2012/17/2 - v0.1.4 - Updated API, added EventDispatcher but not yet tested.
* 2012/14/2 - v0.1.3 - API update.
* 2012/14/2 - v0.1.2 - API update.
* 2012/14/2 - v0.1.1 - Documentation update.
* 2012/14/2 - v0.1.0 - First release on includes extending.
* 2012/13/2 - v0.1.2 - API update.
* 2012/12/2 - v0.1.1 - Documentation update.
* 2012/10/2 - v0.1.0 - First release on includes extending.

@@ -124,2 +125,2 @@ ## New Features

Copyright (c) 2013 Ricky Clegg
Licensed under the APACHE license.
Licensed under the MIT license.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc