
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
bugcore is a JavaScript library that provides a foundational architecture for object oriented JS
bugcore is a JavaScript library that provides a foundational architecture for object oriented JS. It is designed to work both within node js as well as directly in the browser.
bugcore provides a basic class model based on John Resig's simple JavaScript inheritance. In addition the library provides many basic data models and utility classes for common object oriented patterns.
The library is extremely robust and makes up the foundation of our architecture for airbug so check out the docs for an overview of the full power of what the code has to offer. If the library is missing something you need, please let us know!
NOTE: This documentation is still being written. If you click on a link and it doesn't go anywhere, it's likely because that portion of the docs hasn't been written yet. If there are parts of the docs you'd like us to focus on, feel free to ask!
Creation of a new class
var Class = bugcore.Class;
var Obj = bugcore.Obj;
var SomeClassConstructor = Class.extend(Obj, {});
Creation of a new class with an internal _constructor method
var SomeClassConstructor = Class.extend(Obj, {
_constructor: function() {
this._super(); // Call super constructor
}
});
Creation of a new class with overridden equals and hashCode methods
/**
* @class
* @extends {Obj}
*/
var SomeClassConstructor = Class.extend(Obj, {
/**
* @constructs
* @param {number} a
* @param {number} b
*/
_constructor: function(a, b) {
this._super(); // Call super constructor
/**
* @private
* @type {number}
*/
this.a = a;
/**
* @private
* @type {string}
*/
this.b = b
},
/**
* @override
* @param {*} value
* @return {boolean}
*/
equals: function(value) {
if (Class.doesExtend(value, SomeClass)) {
return (Obj.equals(value.a, this.a) && Obj.equals(value.b, this.b));
}
return false;
},
/**
* @override
* @return {number}
*/
hashCode: function() {
if (!this._hashCode) {
this._hashCode = Obj.hashCode("[SomeClass]" +
Obj.hashCode(this.a) + Obj.hashCode(this.b));
}
return this._hashCode;
},
});
Use of a Map
var myMap = new bugcore.Map();
myMap.put("key1", "value1");
myMap.put("key2", "value2");
myMap.get("key1"); // "value1"
myMap.get("key2"); // "value2"
Use of a Map with instances as keys
var myMap = new bugcore.Map();
// SomeClass is from the above example that uses overridden equals and hashCode methods
var instance1 = new SomeClass(123, "abc");
var instance2 = new SomeClass(123, "abc");
myMap.put(instance1, "value");
myMap.put(instance2, "value2");
//hash codes and equality checks are equal therefore the two instances are considered
//the same key even though they are separate instances in memory
myMap.getCount(); // 1
myMap.get(instance1) // "value2"
myMap.get(instance2) // "value2"
bugcore is dependent upon the bugpack framework
The source is available for download from GitHub
From the web, you can download the packaged scripts here
https://s3.amazonaws.com/public-airbug/bugcore-0.3.23.js
https://s3.amazonaws.com/public-airbug/bugcore-0.3.23.min.js
For node js, you can install using Node Package Manager npm
npm install bugcore
For the web, simply include these scripts in your application
<script type="text/javascript" src="https://s3.amazonaws.com/public-airbug/bugpack-0.2.2.min.js"></script>
<script type="text/javascript" src="https://s3.amazonaws.com/public-airbug/bugcore-0.3.23.min.js"></script>
In node js:
npm will install the bugpack dependency
var bugcore = require('bugcore');
var map = new bugcore.Map();
In the browser:
<script type="text/javascript" src="https://s3.amazonaws.com/public-airbug/bugpack-0.2.2.js"></script>
<script type="text/javascript" src="https://s3.amazonaws.com/public-airbug/bugcore-0.3.23.js"></script>
<script type="text/javascript">
var map = new bugcore.Map();
</script>
AddAtChange
AddChange
Change
ClearChange
PutChange
RemoveAtChange
RemoveChange
RemovePropertyChange
SetPropertyChange
BidiMap
Collection
Collections
DependencyGraph
Document
DualMap
DualMultiMap
DualMultiSetMap
Graph
GraphEdge
GraphNode
HashStore
HashStoreNode
HashTable
HashTableNode
List
Map
MultiListMap
MultiMap
MultiSetMap
Pair
Queue
ReferenceGraph
Set
Stack
Striped
Tree
TreeNode
UnorderedPair
Url
WeightedList
WeightedListNode
Event
EventDispatcher
EventListener
EventPropagator
EventQuery
EventQueryBuilder
EventQueryListener
EventReceiver
Flow
Flows
ForEachParallel
ForEachSeries
ForInParallel
ForInSeries
If
IterableParallel
IterableSeries
Iteration
IterableFlow
Parallel
Series
Task
WhileParallel
WhileSeries
Observable
ObservableArray
ObservableCollection
ObservableList
ObservableMap
ObservableObject
ObservableSet
Observation
ObservationPropagator
Observer
ArraySupplier
CollectConsumer
Consumer
EachOperation
FilterOperation
IterableSupplier
MapOperation
ReduceConsumer
Stream
Supplier
Suppliers
ArgUtil
ArrayUtil
Config
DateUtil
HashUtil
HtmlUtil
IdGenerator
LiteralUtil
MathUtil
ObjectUtil
Properties
PropertiesChain
StackTraceUtil
StringUtil
TypeUtil
UuidGenerator
WeightedRandomizer
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
Core class used to build other classes.
Class
/**
* @constructor
* @param {function(new:Constructor)} constructor
* @param {Array.<Interface>} interfaces
* @param {string} name
* @param {Class} superclass
*/
var Class = function(constructor, interfaces, name, superclass) {
Constructor Summary
Access | Signature |
---|---|
constructor | Class({Constructor} constructor, {Array.<Interface>} interfaces, {string} name, {Class} superclass) |
Getters and Setters Summary
Access | Signature | Return Type |
---|---|---|
public | getConstructor() | {function(new:Constructor)} |
public | getInterfaces() | {Array.<Interface>} |
public | getName() | {string} |
public | getSuperclass() | {Class} |
Method Summary
Access | Signature | Return Type |
---|---|---|
public | alloc({*...} args) | {Constructor} |
public | allocWithArray({Array.<*>} args) | {Constructor} |
public | newInstance({*...} args) | {Constructor} |
public | newInstanceWithArray({Array.<*>} args) | {Constructor} |
Static Method Summary
Access | Signature | Return Type |
---|---|---|
static public | declare({Object.<string, *>} declaration) | {function(new:Constructor)} |
static public | doesExtend({*} value, {function(new:Constructor)} constructor) | {boolean} |
static public | doesImplement({*} value, {function(new:Implementable)} implementable) | {boolean} |
static public | extend({function(new:Constructor)} constructor, {Object.<string, *>} declaration) | {function(new:Constructor)} |
static public | implement({function(new:Constructor)} constructor, {function(new:Implementable)} implementable) | None |
Method
/**
* @constructor
* @param {function(new:Constructor)} constructor
* @param {Array.<Interface>} interfaces
* @param {string} name
* @param {Class} superclass
*/
var Class = function(constructor, interfaces, name, superclass) {
Parameters
Name | Type | Description |
---|---|---|
constructor | {function(new:Constructor} | The Constructor of this class. |
interfaces | {Array.<Interface>} | Any Interfaces that this Class implements. |
name | {string} | The name of this Class. |
superclass | {Class} | The superclass of this Class. |
Examples
var myClass = new Class(constructor, interfaces, name, superclass);
Get the Class's Constructor function
Method
/**
* @return {function(new:Constructor)}
*/
getConstructor: function() {
Parameters
Returns
{function(new:Constructor)}
- The Class's Constructor function.Examples
/** @type {function(new:MyClassConstructor)} */
var MyClassConstructor = Class.extend(Obj, {});
/** @type {Class} */
var MyClass = MyClassConstructor.getClass();
console.log(MyClassConstructor === MyClass.getConstructor()); // true
Get the Class's implemented Interfaces
Method
/**
* @return {Array.<Interface>}
*/
getInterfaces: function() {
Parameters
Returns
Examples
var MyInterface = Interface.declare({
myMethod: function() {}
});
var MyClassConstructor = Class.extend(Obj, {
myMethod: function() {}
});
Class.implement(MyClassConstructor, MyInterface);
var MyClass = MyClassConstructor.getClass();
MyClass.getInterfaces(); // [ MyInterface ]
Get the Class's name (if one was supplied)
Method
/**
* @return {string}
*/
getName: function() {
Parameters
Returns
{string}
- The Class's name.Examples
var MyClassConstructor = Class.extend(Obj, {
_name: "MyClass"
});
var MyClass = MyClassConstructor.getClass();
MyClass.getName(); // "MyClass"
Get the Class's superclass (if there is one)
Method
/**
* @return {Class}
*/
getSuperclass: function() {
Parameters
Returns
Examples
Extended Class
var MyClassConstructor = Class.extend(Obj, {});
var MyClass = MyClassConstructor.getClass();
console.log(MyClass.getSuperclass() === Obj.getClass()); // true
Declared Class
var MyBaseClassConstructor = Class.declare({});
var MyBaseClass = MyBaseClassConstructor.getClass();
MyBaseClass.getSuperclass(); // null
This method allocates and returns a new instance of this Class that has only been constructed. It passes all arguments through to the constructor.
Method
/**
* @param {...} args
* @return {Constructor}
*/
alloc: function(args) {
Parameters
Name | Type | Description |
---|---|---|
args | {...} | Any number of arguments of any type. |
Returns
{
Constructor}
- The new instanceExamples
var BaseBall = Class.extend(Ball, {});
var BaseBallClass = BaseBall.getClass();
var myBaseBall = BaseBallClass.alloc("arg1", "arg2");
This method allocates and returns a new instance of this Class that has only been constructed. It uses an array as the arguments to apply to the constructor.
Method
/**
* @param {Array.<*>=} args
* @return {Constructor}
*/
allocWithArray: function(args) {
Parameters
Name | Type | Description |
---|---|---|
args | {Array.<*>} | An array of args to apply to the constructor. |
Returns
{
Constructor}
- The new instanceExamples
var BaseBall = Class.extend(Ball, {});
var BaseBallClass = BaseBall.getClass();
var myBaseBall = BaseBallClass.allocWithArray(["arg1", "arg2"]);
This method returns a new instance of this Class that has been both constructed and initialized. It passes all arguments through to both the constructor as well as the init methods.
Method
/**
* @param {*...} args
* @return {Constructor}
*/
newInstance: function(args) {
Parameters
Name | Type | Description |
---|---|---|
args | {*...} | Any number of arguments of any type. |
Returns
{
Constructor}
- The new instanceExamples
var BaseBall = Class.extend(Ball, {});
var BaseBallClass = BaseBall.getClass();
var myBaseBall = BaseBallClass.newInstance("arg1", "arg2");
This method returns a new instance of this Class that has been both constructed and initialized. It uses an array as the arguments to apply to both the constructor and the init methods.
Method
/**
* @param {Array.<*>=} args
* @return {Constructor}
*/
newInstanceWithArray: function(args) {
Parameters
Name | Type | Description |
---|---|---|
args | {Array.<*>} | An array of args to apply to the constructor and init methods. |
Returns
{
Constructor}
- The new instanceExamples
var BaseBall = Class.extend(Ball, {});
var BaseBallClass = BaseBall.getClass();
var myBaseBall = BaseBallClass.newInstanceWithArray(["arg1", "arg2"]);
This method is used to declare a low level base class in the bugcore system. Most of the time you should not use this method to declare new classes unless you are sure of what you are doing. Instead use the Class.extend method and extend Obj. By using this method, it will exclude many of the base methods that the rest of the bugcore system depends upon, including hashCode, equals, _internalId, and clone
Method
/**
* @static
* @param {Object.<string, *>} declaration
* @return {function(new:Constructor)}
*/
Class.declare = function(declaration) {
Parameters
Name | Type | Description |
---|---|---|
declaration | {Object.<string, *>} | An object that declares the methods of the new class. |
Returns
{function(new:Constructor)}
- The newly created class's constructor.Examples
var LowestLevelObject = Class.declare({
_constructor: function() {
// No need to call this._super, this is the lowest level.
}
});
This method is used to determine if a value extends a particular Constructor's Class. Instances of Classes are considered to extend their own Class.
Method
/**
* @static
* @param {*} value
* @param {function(new:Constructor)} constructor
* @return {boolean}
*/
Class.doesExtend = function(value, constructor) {
Parameters
Name | Type | Description |
---|---|---|
value | {*} | The value to determine if it extends the given Constructor's Class |
constructor | {function(new:Constructor)} | The Constructor used to check if the value extends it's Class |
Returns
{boolean}
- Whether or not the value extends the given Constructor's ClassExamples
var BaseBall = Class.extend(Ball, {});
var myBaseBall = new BaseBall();
Class.doesExtend(myBaseBall, Ball); //true
Class.doesExtend(myBaseBall, BaseBall); //true
This method is used to determine if a value implements a particular Implementable's Interface.
Method
/**
* @static
* @param {*} value
* @param {function(new:Implementable)} implementable
* @return {boolean}
*/
Class.doesImplement = function(value, implementable) {
Parameters
Name | Type | Description |
---|---|---|
value | {*} | The value to determine if it implements the given Implementable's Interface |
constructor | {function(new:Constructor)} | The Constructor used to check if the value extends it's Class |
Returns
{boolean}
- Whether or not the value implements the given Implementable's InterfaceExamples
var IBall = Interface.declare({});
var Ball = Class.declare({});
Class.implement(Ball, IBall);
var myBall = new Ball();
Class.doesImplement(myBall, IBall); //true
This method is used to extend another Class. It accepts the Class's Constructor as a parameter and the declaration for the new Class.
Notes
Method
/**
* @static
* @param {function(new:Constructor)} constructor
* @param {Object.<string, *>} declaration
* @return {function(new:Constructor)}
*/
Class.extend = function(constructor, declaration) {
Parameters
Name | Type | Description |
---|---|---|
constructor | {function(new:Constructor)} | The constructor of the class to extend. |
declaration | {Object.<string, *>} | An object that declares the methods of the new class. |
Returns
{function(new:Constructor)}
- The newly created class's constructor.Examples
var BaseBall = Class.extend(Ball, {
_constructor: function(diameter) {
this._super(); // Call super constructor
this.diameter = diameter;
}
throwBall: function() {
}
});
This method marks a Class as implementing an Interface. When calling this method it will add the Implementable's Interface to the Class's list of Interfaces. It will also validate that the given Class actually implements all of the methods of the Interface. If the Class does not this method will throw an Error.
Method
/**
* @static
* @param {function(new:Constructor)} constructor
* @param {function(new:Implementable)} implementable
*/
Class.implement = function(constructor, implementable) {
Parameters
Name | Type | Description |
---|---|---|
constructor | {function(new:Constructor)} | The Constructor of the Class to implement the Interface. |
implementable | {function(new:Implementable)} | The Implementable of the Interface to implement. |
Returns
Examples
Implement an Interface
var IBall = Interface.declare({
throwBall: function() {}
});
var Ball = Class.declare({
throwBall: function() {
// Implementation of method
}
});
Class.implement(Ball, IBall);
Represents the base instantiable constructor function of all classes declared in the BugCore system using Class.declare
Class
/**
* @constructor
*/
var Constructor = function() {
Getters and Setters Summary
Access | Signature | Return Type |
---|---|---|
public | getClass() | {Class} |
Static Getters and Setters Summary
Access | Signature | Return Type |
---|---|---|
static public | getClass() | {Class} |
Static Methods Summary
Access | Signature | Return Type |
---|---|---|
static public | alloc({*...} args) | {Constructor} |
static public | allocWithArray({Array.<*>} args) | {Constructor} |
static public | newInstance({*...} args) | {Constructor} |
static public | newInstanceWithArray({Array.<*>} args) | {Constructor} |
Get the Class for this instance.
Method
/**
* @return {Class}
*/
getClass: function() {
Parameters
Returns
{Class}
- The Class of this instance.Examples
//TODO BRN: Provide example of Class usage
Get the Class for this Constructor.
Method
/**
* @static
* @return {Class}
*/
Constructor.getClass = function() {
Parameters
Returns
{Class}
- The Class of this Constructor.Examples
//TODO BRN: Provide example of Class usage
This method allocates and returns a new instance of the class represented by this Constructor. The new instance has only been constructed and not initialized. The method passes all arguments through to the constructor.
Method
/**
* @static
* @param {*...}
* @return {Constructor}
*/
Constructor.alloc = function() {
Parameters
Name | Type | Description |
---|---|---|
args | {...} | Any number of arguments of any type. |
Returns
{
Constructor}
- The new instanceExamples
var BaseBall = Class.extend(Ball, {});
var myBaseBall = BaseBall.alloc("arg1", "arg2");
This method allocates and returns a new instance of the class represented by this Constructor. The new instance has only been constructed and not initialized. This method uses an array as the arguments to apply to the constructor.
Method
/**
* @static
* @param {Array.<*>} args
* @return {Constructor}
*/
Constructor.allocWithArray = function(args) {
Parameters
Name | Type | Description |
---|---|---|
args | {Array.<*>} | An array of args to apply to the constructor. |
Returns
{
Constructor}
- The new instanceExamples
var BaseBall = Class.extend(Ball, {});
var myBaseBall = BaseBall.allocWithArray(["arg1", "arg2"]);
This method allocates and returns a new instance of the class represented by this Constructor. The new instance has been both constructed and initialized. This method passes all arguments through to both the constructor as well as the init methods.
Method
/**
* @static
* @param {*...}
* @return {Constructor}
*/
Constructor.newInstance = function() {
Parameters
Name | Type | Description |
---|---|---|
args | {*...} | Any number of arguments of any type. |
Returns
{
Constructor}
- The new instanceExamples
var BaseBall = Class.extend(Ball, {});
var myBaseBall = BaseBall.newInstance("arg1", "arg2");
This method allocates and returns a new instance of the class represented by this Constructor. The new instance has been both constructed and initialized. This method uses an array as the arguments to apply to both the constructor and the init methods.
Method
/**
* @static
* @param {Array.<*>} args
* @return {Constructor}
*/
Constructor.newInstanceWithArray = function(args) {
Parameters
Name | Type | Description |
---|---|---|
args | {Array.<*>} | An array of args to apply to the constructor and init methods. |
Returns
{
Constructor}
- The new instanceExamples
var BaseBall = Class.extend(Ball, {});
var myBaseBall = BaseBall.newInstanceWithArray(["arg1", "arg2"]);
Represents the base function of all interfaces declared in the BugCore system using Interface.declare
Class
/**
* @constructor
*/
var Implementable = function() {};
Static Getters and Setters Summary
Access | Signature | Return Type |
---|---|---|
static public | getInterface() | {Interface} |
Get the Interface for this Implementable.
Method
/**
* @static
* @return {Interface}
*/
Implementable.getInterface = function() {
Parameters
Returns
{Interface}
- The Interface of this Implementable.Examples
var MyImplementable = Interface.declare({
interfaceMethod: function() {
}
});
var MyInterface = MyImplementable.getInterface();
Core class used to build interfaces.
Class
/**
* @constructor
* @param {function(new:Implementable)} implementable
* @param {string} name
* @param {Interface} superinterface
*/
var Interface = function(implementable, name, superinterface) {
Constructor Summary
Access | Signature
--- | --- | ---
constructor | Interface({function(new:Implementable)} implementable, {string} name, {Interface} superinterface)
Getters and Setters Summary
Access | Signature | Return Type |
---|---|---|
public | getImplementable() | {function(new:Implementable)} |
public | getName() | {string} |
public | getSuperinterface() | {Interface} |
Static Method Summary
Access | Signature | Return Type |
---|---|---|
static public | declare({Object.<string, *>} declaration) | {function(new:Implementable)} |
static public | extend({function(new:Implementable)} implementable, {Object.<string, *>} declaration) | function(new:Implementable) |
Constructor for a new Interface. This should not be used directly. Instead, use the Interface.declare method to create a new Interface.
Method
/**
* @constructor
* @param {function(new:Implementable)} implementable
* @param {string} name
* @param {Interface} superinterface
*/
var Interface = function(implementable, name, superinterface) {
Parameters
Name | Type | Description |
---|---|---|
implementable | {function(new:Implementable} | The Implementable of this Interface. |
name | {string} | The name of this Interface. |
superinterface | {Interface} | The superinterface of this Interface (optional). |
Examples
var myInterface = new Interface(implementable, name, superinterface);
Get the Interface's Implementable function.
Method
/**
* @return {function(new:Implementable)}
*/
getImplementable: function() {
Parameters
Returns
{function(new:
Implementable)}
- The Interface's Implementable function.Examples
/** @type {function(new:MyInterfaceImplementable)} */
var MyInterfaceImplementable = Interface.declare({});
/** @type {Interface} */
var MyInterface = MyInterfaceImplementable.getInterface();
console.log(MyInterfaceImplementable === MyInterface.getImplementable()); // true
Get the Interface's name (if one was supplied)
Method
/**
* @return {string}
*/
getName: function() {
Parameters
Returns
{string}
- The Interface's name.Examples
var MyInterfaceImplementable = Interface.declare({
_name: "MyInterface"
});
var MyInterface = MyInterfaceImplementable.getInterface();
MyInterface.getName(); // "MyInterface"
Get the Interface's superinterface (if there is one)
Method
/**
* @return {Interface}
*/
getSuperinterface: function() {
Parameters
Returns
Examples
Extended Interface
var MyInterfaceImplementable = Interface.extend(SomeInterfaceImplementable, {});
var MyInterface = MyInterfaceImplementable.getInterface();
console.log(MyInterface.getSuperinterface() === SomeInterfaceImplementable.getInterface()); // true
Declared Interface
var MyBaseInterfaceImplementable = Interface.declare({});
var MyBaseInterface = MyBaseInterfaceImplementable.getInterface();
MyBaseInterface.getSuperinterface(); // null
This method is used to declare a low level base Interface in the bugcore system. Unlike Class.declare this method should be freely used to declare basic interfaces that extend no other Interface.
Method
/**
* @static
* @param {Object.<string, function(...):*>} declaration
* @return {function(new:Implementable)}
*/
Interface.declare = function(declaration) {
Parameters
Name | Type | Description |
---|---|---|
declaration | {Object.<string, function(...):*>} | An object that declares the methods of the new Interface. |
Returns
{function(new:
Implementable)}
- The newly created Interface's Implementable.Examples
var MyImplementable = Interface.declare({
foo: function() {},
bar: function() {}
});
This method is used to extend and existing interface.
Method
/**
* @static
* @param {function(new:Implementable)} implementable
* @param {Object.<string, function(..):*>} declaration
* @return {function(new:Implementable)}
*/
Interface.extend = function(implementable, declaration) {
Parameters
Name | Type | Description |
---|---|---|
implementable | {function(new:Implementable)} | The Implementable of the Interface to extend. |
declaration | {Object.<string, function(...):*>} | An object that declares the methods of the new Interface. |
Returns
{function(new:
Implementable)}
- The newly created Interface's Implementable.Examples
var IBall = Interface.declare({
throwBall: function() {
}
});
var IBaseBall = Class.extend(IBall, {
hitBall: function() {
}
});
The root class of all other classes in the bugcore library. Provides basic functionality such as hash code support, equality checks and clone support.
Class
/**
* @class
* @extends {Constructor}
* @implements {IClone}
* @implements {IEquals}
* @implements {IHashCode}
*/
var Obj = Class.declare(/** @lends {Obj.prototype} */{
Extends
Interfaces
Constructor Summary
Access | Signature |
---|---|
constructor | _constructor() |
Getters and Setters Summary
Access | Signature | Return Type |
---|---|---|
public | getInternalId() | {number} |
Method Summary
Access | Signature | Return Type |
---|---|---|
public | clone({boolean} deep) | {*} |
public | equals({*} value) | {boolean} |
public | hashCode() | {number} |
Static Method Summary
Access | Signature | Return Type |
---|---|---|
static public | clone({A} value, {boolean} deep) | {A} |
static public | equals({*} value1, {*} value2) | {boolean} |
static public | hashCode({*} value) | {number} |
Method
/**
* @constructs
*/
_constructor: function() {
Parameters
Examples
var myObj = new Obj();
Method
/**
* @return {number}
*/
getInternalId: function() {
Parameters
Returns
{number}
- The unique internal id for this instance. Unique only to this JS runtime.Examples
var myObj = new Obj();
var internalId = myObj.getInternalId();
By default the clone method will use the instance's Class to instantiate a new instance. It will also iterate through the instance's properties and attempt to clone all properties that are not functions. If a deep clone is being performed, then the clone method will attempt to create a deep copy of each property. If a shallow clone is being performed then a reference to the property value will be set on the new instance.
Notes
Method
/**
* @param {boolean=} deep
* @return {*}
*/
clone: function(deep) {
Parameters
Name | Type | Description |
---|---|---|
deep | {boolean=} | Whether or not to perform a deep clone. Optional - default: false |
Returns
{*}
- A clone of the instance.Examples
var myObj = new Obj();
var shallowCloneObj = myObj.clone(); //shallow clone
var deepCloneObj = myObj.clone(true); //deep clone
By default, the equality check will compare this instances _internalId to the value parameter.
Notes
Method
/**
* @param {*} value
* @return {boolean}
*/
equals: function(value) {
Parameters
Name | Type | Description |
---|---|---|
value | {*} | The value to compare to for equality. |
Returns
{boolean}
- Whether or not the instance is equal to the value parameter.Examples
Two different instances are not equal
var obj1 = new Obj();
var obj2 = new Obj();
obj1.equals(obj2); //false
An instance is equal to itself
var obj1 = new Obj();
obj1.equals(obj1); //true
Clones are not equal unless the 'equals' method is overridden
var obj = new Obj();
var objClone = obj.clone();
obj.equals(objClone); //false
var obj = new Obj();
var objClone = obj.clone(true);
obj.equals(objClone); //false
Returns the objects hashCode. The generation of the hashCode is only run once and then cached.
Notes
Method
/**
* @return {number}
*/
hashCode: function() {
Parameters
Returns
{number}
- The hash code of this instance.Examples
Get hash code of instance
var obj = new Obj();
var hashCode = obj.hashCode();
Clones the value parameter.
If the value implements IClone the clone() method will be called to perform a clone of the value. If the value is a basic value such as a number or string it will simply be passed through.
Method
/**
* @static
* @param {A} value
* @param {boolean=} deep
* @return {A}
* @template A
*/
Obj.clone = function(value, deep) {
Notes
Parameters
Name | Type | Description |
---|---|---|
value | {A} | The value to clone. |
deep | {boolean=} | Whether or not to perform a deep clone. Optional - default: false |
Returns
{A}
- A clone of the value.Examples
var myObj = new Obj();
var shallowCloneObj = Obj.clone(myObj); //shallow clone
var myObj = new Obj();
var deepCloneObj = Obj.clone(myObj, true); //deep clone
var myString = "abc123";
var cloneString = Obj.clone(myString); //"abc123"
Checks value1 and value2 for equality.
If value1 implements IEquals, the value1.equals() method will be used to perform the equality check. Otherwise === is used to compare the two values.
Notes
Method
/**
* @static
* @param {*} value1
* @param {*} value2
* @return {boolean}
*/
Obj.equals = function(value1, value2) {
Parameters
Name | Type | Description |
---|---|---|
value1 | {*} | The value to compare value2 to for equality. |
value2 | {*} | The value to compare value1 to for equality. |
Returns
{boolean}
- Whether or not the two values are equal.Examples
Two different instances are not equal
var obj1 = new Obj();
var obj2 = new Obj();
Obj.equals(obj1, obj2); //false
An instance is equal to itself
var obj1 = new Obj();
Obj.equals(obj1, obj1); //true
Strings of the same value are equal
var string1 = "mystring";
var string2 = "mystring";
Obj.equals(string1, string2) //true
Undefined and null are not equal
var undefinedValue = undefined;
var nullValue = null;
Obj.equals(undefinedValue, nullValue) //false
Two Dates of the same time are equal
var time = Date.now();
var date1 = new Date(time);
var date2 = new Date(time);
Obj.equals(date1, date2) //true
Returns the hashCode of the value. If the value implements IHashCode, then the value.hashCode() method will be used to generate the hash code.
Method
/**
* @static
* @param {*} value
* @return {number}
*/
Obj.hashCode = function(value) {
Parameters
Name | Type | Description |
---|---|---|
value | {*} | The value to generate a hash code for.. |
Returns
{number}
- The hash code of the value.Examples
Get hash code of an instance.
var myObj = new Obj();
var hashCode = Obj.hashCode(myObj);
Get hash code of a string.
var myString = "abc123";
var hashCode = Obj.hashCode(myString);
The base interface for cloning. If your Class can be cloned, you should implement this interface.
Interface
/**
* @interface
*/
var IClone = Interface.declare({
Method Summary
Access | Signature | Return Type |
---|---|---|
public | clone({boolean=} deep) | {*} |
This method returns a clone of the instance that implements this interface. Implementations should respect the deep clone flag.
Notes
Method
/**
* @param {boolean=} deep
* @return {*}
*/
clone: function(deep) {}
Parameters
Name | Type | Description |
---|---|---|
deep | {boolean=} | Whether or not to perform a deep clone. Optional - default: false |
Returns
{*}
- A clone of the instance.The base interface for equality checks. If your Class can be compared for equality against another, you should implement this interface.
Notes
Interface
/**
* @interface
*/
var IEquals = Interface.declare({
Method Summary
Access | Signature | Return Type |
---|---|---|
public | equals({*} value) | {boolean} |
This method returns true if the instance that implements this interface is equal to the given value. Returns false if the given value does not equal the instance.
Notes
Method
/**
* @param {*} value
* @return {boolean}
*/
equals: function(value) {}
Parameters
Name | Type | Description |
---|---|---|
value | {*} | The value to compare the instance against for equality. |
Returns
{boolean}
- Returns true if the instance is equal to the given value. False if not.The base interface for generating a hash code for an instance. Used in tandem with the IEquals interface for storing values in HashStore and HashTable.
Notes
Interface
/**
* @interface
*/
var IHashCode = Interface.declare({
Method Summary
Access | Signature | Return Type |
---|---|---|
public | hashCode() | {number} |
This method returns a hash code for the current instance.
Notes
Method
/**
* @return {number}
*/
hashCode: function() {}
Parameters
Returns
{number}
- The hash code for the instance.The root throwable class of the bugcore system. Has support for more complex stack traces including cause chains.
Class
/**
* @class
* @extends {Obj}
* @implements {IObjectable}
*/
var Throwable = Class.extend(Obj, {
Extends
Interfaces
Constructor Summary
Access | Signature |
---|---|
public | _constructor({string} type, {*=} data, {string=} message, {Array.<(Throwable | Error)>=} causes) |
Getters and Setters Summary
Access | Signature | Return Type |
---|---|---|
public | getCauses() | {Array.<(Throwable | Error)>} |
public | getData() | {*} |
public | setData({*} data) | None |
public | getMessage() | {string} |
public | setMessage({string} message) | None |
public | getStack() | {string} |
public | getType() | {string} |
Method Summary
Access | Signature | Return Type |
---|---|---|
public | addCause({(Throwable | Error)} cause) | {*} |
public | toObject() | {causes: Array.<(Throwable | Error)>, data: *, message: string, type: string} |
Method
/**
* @constructs
* @param {string} type
* @param {*=} data
* @param {string=} message
* @param {Array.<(Throwable | Error)>=} causes
*/
_constructor: function(type, data, message, causes) {
Parameters
Name | Type | Description |
---|---|---|
type | {string} | The type of throwable. |
data | {*=} | Any extra data to pass along with this throwable. |
message | {string=} | A message to add to this throwable. (optional - default: "") |
causes | {Array.<(Throwable | Error)>=} | An array of other throwables or js errors that caused this throwable. (optional - default: []) |
Examples
Simple throwable
var myThrowable = new Throwable("MyThrowable", {}, "Something bad happened");
throw myThrowable;
Throwable with cause
try {
somethingWillGoWrong();
} catch (error) {
var myThrowable = new Throwable("SomethingWentWrong", {}, "Something went wrong in the somethingWillGoWrong function", [error]);
throw throwable;
}
Get the causes of the Throwable.
Method
/**
* @return {Array.<(Throwable | Error)>}
*/
getCauses: function() {
Parameters
Returns
{
Array.<(Throwable | Error)>}
- An array of other Throwables or JS Errors that caused this Throwable.Examples
try {
somethingWillGoWrong();
} catch (error) {
var myThrowable = new Throwable("SomethingWentWrong", {}, "Something went wrong in the somethingWillGoWrong function", [error]);
var causes = myThrowable.getCauses(); // [error]
}
Get the data of the Throwable.
Method
/**
* @return {*}
*/
getData: function() {
Parameters
Returns
{*}
- An array of other Throwables or JS Errors that caused this Throwable.Examples
var data = "some data";
var myThrowable = new Throwable("ThrowableType", data, "some message");
myThrowable.getData() === data; //true
Set the data of the Throwable.
Method
/**
* @param {*} data
*/
setData: function(data) {
Parameters
Name | Type | Description |
---|---|---|
data | {*} | The data to set on the Throwable. |
Returns
Examples
var data = "some data";
var myThrowable = new Throwable("ThrowableType");
myThrowable.setData(data);
myThrowable.getData() === data; //true
Get the message of the Throwable.
Method
/**
* @return {string}
*/
getMessage: function() {
Parameters
Returns
{string}
- The message included with the Throwable.Examples
var message = "some message";
var myThrowable = new Throwable("ThrowableType", null, message);
myThrowable.getMessage() === message; //true
Set the message of the Throwable.
Method
/**
* @param {string} message
*/
setMessage: function(message) {
Parameters
Name | Type | Description |
---|---|---|
message | {string} | The message to set on the Throwable. |
Returns
Examples
var message = "some message";
var myThrowable = new Throwable("ThrowableType");
myThrowable.setMessage(message);
myThrowable.getMessage() === message; //true
Get the stack trace of the Throwable.
Method
/**
* @return {string}
*/
getStack: function() {
Parameters
Returns
{string}
- The stack trace of the Throwable.Examples
//TODO
Get the type of the Throwable.
Method
/**
* @return {string}
*/
getType: function() {
Parameters
Returns
{string}
- The type of the Throwable.Examples
var myThrowable = new Throwable("ThrowableType");
myThrowable.getType() === "ThrowableType"; //true
Add a cause to the Throwables list of causes.
Notes
Method
/**
* @param {(Throwable | Error)} cause
*/
addCause: function(cause) {
Parameters
Name | Type | Description |
---|---|---|
cause | {(Throwable | Error)} | The cause to add to the Throwable's array of causes. |
Returns
Examples
Add multiple causes to a single throwable
var myThrowable = new Throwable("MultipleCauses", {}, "Several things went wrong");
//We want this to complete the looping even if a throwable occurs.
for (var i = 0; i < 10; i++) {
try {
somethingMightGoWrong();
} catch (error) {
myThrowable.addCause(error);
}
}
TODO
The root class of several of the data objects. A collection represents a group of items.
Notes
Class
/**
* @class
* @extends {Obj}
* @implements {IArrayable}
* @implements {ICollection.<I>}
* @implements {IIterable}
* @template I
*/
var Collection = Class.extend(Obj, /** @lends {Collection.prototype} */{
Extends
Interfaces
Constructor Summary
Access | Signature |
---|---|
public | _constructor({(ICollection.<I> | Array.<I>)} items) |
Getters and Setters Summary
Access | Signature | Return Type |
---|---|---|
public | getHashStore() | {HashStore} |
Method Summary
Access | Signature | Return Type |
---|---|---|
public | add({I} item) | {boolean} |
public | addAll({(ICollection.<I> | Array.<I>)} items) | None |
public | clear() | None |
public | contains({*} value) | {boolean} |
public | containsAll({(ICollection.<*> | Array.<*>)} values) | {boolean} |
public | containsEqual({(ICollection.<*> | Array.<*>)} values) | {boolean} |
public | forEach({function(I)} func) | None |
public | getCount() | {number} |
public | [toValueArray](#Collection_toValueArray() | {Array.<I>} |
public | countValue({*} value) | {number} |
public | isEmpty() | {boolean} |
public | iterator() | {IIterator} |
public | map({function} fn, {Object} context) | {ICollection} |
public | remove({*} value) | {boolean} |
public | removeAll({(ICollection.<*> | Array.<*>)} values) | None |
public | retainAll({(ICollection.<*> | Array.<*>)} values) | None |
public | toArray() | {Array.<I>} |
Method
/**
* @constructs
* @param {(ICollection.<I> | Array.<I>)=} items
*/
_constructor: function(items) {
Parameters
Name | Type | Description |
---|---|---|
items | {(ICollection.<I> | Array.<I>)=} | Starting items to add to the Collection (Optional) |
Returns
Examples
No parameters
var myCollection = new Collection();
Array parameter
var items = [
"item1",
"item2"
];
var myCollection = new Collection(values);
Other Collection parameter
var itemsCollection = new Collection([
"item1",
"item2"
]);
var myCollection = new Collection(itemsCollection);
Method
/**
* @return {HashStore}
*/
getHashStore: function() {
Parameters
Returns
Examples
var myCollection = new Collection();
var hashStore = myCollection.getHashStore();
Adds an item to the collection
Method
/**
* @param {I} item
* @return {boolean}
*/
add: function(item) {
Parameters
Name | Type | Description |
---|---|---|
item | {I} | The item to add to the collection |
Returns
{boolean}
- Whether or not the item was added to the collection.Examples
var myCollection = new Collection();
var myItem = "myItem";
var result = myCollection.add(myItem); // true
Adds an Array or Collection of items to the Collection
Method
/**
* @param {(ICollection.<I> | Array.<I>)} items
*/
addAll: function(items) {
Parameters
Name | Type | Description |
---|---|---|
items | {(ICollection.<I> | Array.<I>)} | The items to add to the collection. Can either be an Array or another Collection. |
Returns
Examples
Add an array of items.
var myCollection = new Collection();
var myItems = [
"item1",
"item2"
];
myCollection.addAll(myItems);
Add a Collection of items.
var myCollection = new Collection();
var itemsCollection = new Collection([
"item1",
"item2"
]);
myCollection.addAll(itemsCollection);
Removes all of the items from this collection.
Method
/**
*
*/
clear: function() {
Parameters
Returns
Examples
Empty the Collection
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.getCount(); // 2
myCollection.clear();
myCollection.getCount(); // 0
Checks the Collection to see if it contains a value.
Method
/**
* @param {*} value
* @return {boolean}
*/
contains: function(value) {
Parameters
Name | Type | Description |
---|---|---|
value | {*} | The value that we're checking if the collection contains. |
Returns
{boolean}
- True if the value is contained by the Collection. False if not.Examples
Value not contained
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.contains("item3"); // false
Value contained
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.contains("item2"); // true
Checks the Collection to see if it contains all of the values in the given argument. If ALL of the values are contained by the collection, this method will return true. Otherwise, false.
Notes
Method
/**
* @param {(ICollection.<*> | Array.<*>)} values
* @return {boolean}
*/
containsAll: function(values) {
Parameters
Name | Type | Description |
---|---|---|
values | {(ICollection.<*> | Array.<*>)} | The values that we're checking to see if the collection contains all of them. |
Returns
{boolean}
- True if the Collection contains all the given values. False if not.Examples
Values not contained
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.containsAll(["item3"]); // false
Partial values contained are not a match.
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.containsAll(["item2", "item3"]); // false
Values contained
var myCollection = new Collection([
"item1",
"item2",
"item3"
]);
myCollection.containsAll(["item2", "item3"]); // true
Exact match is true
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.containsAll(["item1", "item2"]); // true
Multiple elements are ignored. Match is true.
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.containsAll(["item1", "item2", "item2"]); // true
Empty collections are contained by any collection
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.containsAll([]); // true
Checks the Collection to see if it contains exactly the values in the given argument. If the collection contains the exact same values as the collection given in the parameter, this method will return true. Otherwise, false.
Method
/**
* @param {(ICollection.<*> | Array.<*>)} values
* @return {boolean}
*/
containsEqual: function(values) {
Parameters
Name | Type | Description |
---|---|---|
values | {(ICollection.<*> | Array.<*>)} | The values that we're checking to see if the collection contains exactly. |
Returns
{boolean}
- True if the Collection contains exactly the same values as the given values.Examples
Values not contained at all
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.containsEqual(["item3"]); // false
Partial values contained are not a match.
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.containsEqual(["item2", "item3"]); // false
Values contained but not an exact match
var myCollection = new Collection([
"item1",
"item2",
"item3"
]);
myCollection.containsEqual(["item2", "item3"]); // false
Exact match is true
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.containsEqual(["item1", "item2"]); // true
Exact match out of order is true
var myCollection = new Collection([
"item2",
"item1"
]);
myCollection.containsEqual(["item1", "item2"]); // true
Multiple elements are considered
var myCollection = new Collection([
"item1",
"item2",
"item2"
]);
myCollection.containsEqual(["item1", "item2"]); // false
forEach executes the provided function once for each element of the Collection.
Notes
Method
/**
* @param {function(I)} func
*/
forEach: function(func) {
Parameters
Name | Type | Description |
---|---|---|
func | {function(I)} | The function to execute for each item |
Returns
Examples
Execute for each item
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.forEach(function(item) {
console.log(item); // item1 on first pass, item2 on second
});
Partial values contained are not a match.
var myCollection = new Collection([]);
myCollection.forEach(function(item) {
console.log(item); // never executed
});
Returns the number of items in the collection.
Method
/**
* @return {number}
*/
getCount: function() {
Parameters
Returns
{number}
- The number of items in the Collection.Examples
Empty Collection
var myCollection = new Collection([]);
myCollection.getCount(); //0
Starts with 2 items
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.getCount() //2
Returns an Array of the Collection's values.
Notes
Method
/**
* @return {Array.<I>}
*/
toValueArray: function() {
Parameters
Returns
Examples
Empty Collection
var myCollection = new Collection([]);
myCollection.toValueArray(); // []
Starts with 2 items (order of items shown in examples is not indicative of real world results)
var myCollection = new Collection([
"item1",
"item2"
]);
myCollection.toValueArray() // ["item1", "item2"]
Manipulation of Collection after array is returned. (order of items shown in examples is not indicative of real world results)
var myCollection = new Collection([
"item1",
"item2"
]);
var myValueArray = myCollection.toValueArray();
myCollection.add("item3") // ["item1", "item2"]
console.log(myCollection.toValueArray()) // ["item1", "item2", "item3"]
console.log(myValueArray) // ["item1", "item2"]
Returns an the number or items in the Collection that are equal to the given value.
Method
/**
* @param {*} value
* @return {number}
*/
countValue: function(value) {
Parameters
Returns
{number}
- The number of items in the Collection that are equal to the given value.Examples
var myCollection = new Collection([
"a",
"a",
"b"
]);
myCollection.countValue("a"); // 2
myCollection.countValue("b"); // 1
myCollection.countValue("c"); // 0
Returns true if the Collection is empty.
Method
/**
* @return {boolean}
*/
isEmpty: function() {
Parameters
Returns
{true}
- True if the Collection is empty.Examples
Empty Collection
var myCollection = new Collection([]);
myCollection.isEmpty(); // true
Not empty Collection
var myCollection = new Collection([
"a"
]);
myCollection.isEmpty(); // false
This method generates an iterator for this Collection.
Notes
Method
/**
* @return {IIterator}
*/
iterator: function() {
Parameters
Returns
Examples
Iterate Collection
var myCollection = new Collection([
"a",
"b",
"c"
]);
var iterator = myCollection.iterator();
while (iterator.hasNext()) {
var value = iterator.next();
}
Iterate past end of Collection
var myCollection = new Collection([
"a",
"b",
"c"
]);
var iterator = myCollection.iterator();
iterator.next(); // "a"
iterator.next(); // "b"
iterator.next(); // "c"
iterator.next(); // throws and Exception of type "NoSuchElement"
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
The root event class for all other events in the bugcore system.
Notes
Class
/**
* @class
* @extends {Obj}
*/
var Event = Class.extend(Obj, /** @lends {Event.prototype} */{
Extends
Constructor Summary
Access | Signature |
---|---|
constructor | Event({string} type, {*} data) |
Getters and Setters Summary
Access | Signature | Return Type |
---|---|---|
public | getBubbles() | {boolean} |
public | setBubbles({boolean}) | None |
public | getCurrentTarget() | {*} |
public | setCurrentTarget({*} currentTarget) | None |
public | getData() | {*} |
public | getTarget() | {*} ] |
public | setTarget({*} target) | None |
public | getType() | {string} |
Method Summary
Access | Signature | Return Type |
---|---|---|
public | isPropagationStopped() | {boolean} |
public | [stopPropagation(#Event_stopPropagation)() | None |
Method
/**
* @constructs
* @param {string} type
* @param {*=} data
*/
_constructor: function(type, data) {
Parameters
Name | Type | Description |
---|---|---|
type | {string} | The type of this event |
data | {*=} | Any data to pass along with this Event (Optional) |
Examples
Simple instantiation
var myEvent = new Event("MyEvent");
Dispatching an event
var myDispatcher = new EventDispatcher();
myDispatcher.dispatchEvent(new Event("MyEvent", {my: "data"}));
Whether or not this Event bubbles
Notes
Method
/**
* @return {boolean}
*/
getBubbles: function() {
Parameters
Returns
{boolean}
- Whether or not this event bubblesExamples
var myEvent = new Event();
myEvent.getBubbles(); // true
Set whether or not this Event should bubble
Notes
Method
/**
* @param {boolean} bubbles
*/
setBubbles: function(bubbles) {
Parameters
Name | Type | Description |
---|---|---|
bubbles | {boolean} | The value to set for bubbles |
Returns
Examples
var myEvent = new Event();
myEvent.getBubbles(); // true
Returns whether or not propagation of this event has stopped.
Notes
stopPropagation()
]("#Event_stopPorpagation"]Method
/**
* @return {boolean}
*/
isPropagationStopped: function() {
Parameters
Returns
{boolean}
- Whether or not propagation of this event has stopped.Examples
var myEvent = new Event();
myEvent.isPropagationStopped(); // false;
myEvent.stopPropagation();
myEvent.isPropagationStopped(); // true;
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
Utility class for determining the data type of values.
Class
/**
* @constructor
*/
var TypeUtil = function() {
Static Method Summary
Access | Signature | Return Type |
---|---|---|
static | isArguments({*} value) | {boolean} |
static | isArray({*} value) | {boolean} |
static | isBoolean({*} value) | {boolean} |
static | isDate({*} value) | {boolean} |
static | isFunction({*} value) | {boolean} |
static | isNan({*} value) | {boolean} |
static | isNull({*} value) | {boolean} |
static | isNumber({*} value) | {boolean} |
static | isObject({*} value) | {boolean} |
static | isRegExp({*} value) | {boolean} |
static | isString({*} value) | {boolean} |
static | isUndefined({*} value) | {boolean} |
static | toType({*} value) | {string} |
Determines if the given value is a native js arguments list.
Method
/**
* @static
* @param {*} value
* @return {boolean}
*/
TypeUtil.isArguments = function(value) {
Parameters
value {*}
- The value to check for the type of argumentsReturns
{boolean}
- Whether or not the value is an arguments.Examples
Arguments literal is an arguments
var myFunction = function() {
TypeUtil.isArguments(arguments); //true
}
Instance of Array is not an arguments
var myArray = [];
TypeUtil.isArguments(myArray); //false
Determines if the given value is an array.
Method
/**
* @static
* @param {*} value
* @return {boolean}
*/
TypeUtil.isArray = function(value) {
Parameters
value {*}
- The value to check for the type of arrayReturns
{boolean}
- Whether or not the value is an array.Examples
Array literal is an array
var myArray = [];
TypeUtil.isArray(myArray); //true
Instance of Array is an array
var myArray = new Array();
TypeUtil.isArray(myArray); //true
Instance of Collection is NOT an array
var myCollection = new Collection();
TypeUtil.isArray(myCollection); //false
number is NOT an array
var myNumber = 123;
TypeUtil.isArray(myNumber); //false
Determines if the given value is a boolean.
Method
/**
* @static
* @param {*} value
* @return {boolean}
*/
TypeUtil.isBoolean = function(value) {
Parameters
value {*}
- The value to check for the type of booleanReturns
{boolean}
- Whether or not the value is a boolean.Examples
Boolean literal true is a boolean
var myTrueBoolean = true;
TypeUtil.isBoolean(myTrueBoolean); //true
Boolean literal false is a boolean
var myFalseBoolean = false;
TypeUtil.isBoolean(myFalseBoolean); //true
Instance of a true Boolean is a boolean
var myTrueBoolean = new Boolean(true);
TypeUtil.isBoolean(myTrueBoolean); //true
Instance of a true Boolean is a boolean
var myFalseBoolean = new Boolean(false);
TypeUtil.isBoolean(myFalseBoolean); //true
the number 0 is NOT a boolean
var myNumber = 0;
TypeUtil.isBoolean(myNumber); //false
TODO
TODO
TODO
TODO
TODO
TODO
FAQs
bugcore is a JavaScript library that provides a foundational architecture for object oriented JS
The npm package bugcore receives a total of 0 weekly downloads. As such, bugcore popularity was classified as not popular.
We found that bugcore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.