-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π Add more default traps to the
Magic
class
- Loading branch information
Showing
3 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ Magic.setMethod(function __get(name) { | |
}); | ||
|
||
/** | ||
* MAgic property setter | ||
* Magic property setter | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.6.6 | ||
|
@@ -57,6 +57,63 @@ Magic.setMethod(function __set(name, value) { | |
return this[name] = value; | ||
}); | ||
|
||
/** | ||
* Magic delete handler | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.9.5 | ||
* @version 0.9.5 | ||
* | ||
* @param {string} name | ||
*/ | ||
Magic.setMethod(function __delete(name) { | ||
return delete this[name]; | ||
}); | ||
|
||
/** | ||
* Get the "own" keys | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.9.5 | ||
* @version 0.9.5 | ||
*/ | ||
Magic.setMethod(function __ownKeys() { | ||
return Object.keys(this); | ||
}); | ||
|
||
/** | ||
* See if this property exists | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.9.5 | ||
* @version 0.9.5 | ||
*/ | ||
Magic.setMethod(function has(name) { | ||
return typeof this[name] != 'undefined' && name in this; | ||
}); | ||
|
||
/** | ||
* Define a property | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.9.5 | ||
* @version 0.9.5 | ||
*/ | ||
Magic.setMethod(function __define(key, descriptor) { | ||
return Object.defineProperty(this, key, descriptor); | ||
}); | ||
|
||
/** | ||
* Get a property descriptor | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.9.5 | ||
* @version 0.9.5 | ||
*/ | ||
Magic.setMethod(function __describe(key) { | ||
return Object.getOwnPropertyDescriptor(this, key); | ||
}); | ||
|
||
/** | ||
* The actual traps | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "protoblast", | ||
"description": "Native object expansion library", | ||
"version": "0.9.4", | ||
"version": "0.9.5-alpha", | ||
"author": "Jelle De Loecker <[email protected]>", | ||
"keywords": [ | ||
"prototype", | ||
|