Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/konapun/watcher.js
Add before/after method modifiers to your Javascript objects
https://github.com/konapun/watcher.js
Last synced: 22 days ago
JSON representation
Add before/after method modifiers to your Javascript objects
- Host: GitHub
- URL: https://github.com/konapun/watcher.js
- Owner: konapun
- Created: 2013-09-28T22:57:31.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-29T00:19:12.000Z (about 11 years ago)
- Last Synced: 2024-04-14T19:58:15.498Z (7 months ago)
- Language: JavaScript
- Size: 102 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Watcher
Add before/after method modifiers to your objectsThis is just a project I did to play around with Function.apply and is not meant
to be used in production.### Usage
```js
var myObj = {
sayHello: function(name) {
console.log("Hello, " + name);
}
};var watchedObj = Watcher.watch(myObj);
watchedObj.before('sayHello', function(name) {
console.log("About to say hello...");
});
watchedObj.after('sayHello' function(name) {
console.log("You're a real nice person, " + name);
});watchedObj.sayHello('konapun'); // writes "About to say hello..." "Hello, konapun" "You're a real nice person, konapun"
```