-
Notifications
You must be signed in to change notification settings - Fork 51
added a new method: pwn #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /*global module:true, window:true, require:false, define:false*/ | ||
| (function() { | ||
| (function () { | ||
| 'use strict'; | ||
|
|
||
| // Bromise... it's stronger than a Promise | ||
|
|
@@ -10,21 +10,21 @@ | |
| } | ||
|
|
||
| Bromise.brototype = Bromise.prototype = { | ||
| "butWhenIdo": function(callback, context) { | ||
| "butWhenIdo": function (callback, context) { | ||
| if (this.method instanceof Function) { | ||
| var returnValue = this.method.apply(this.object, this.args); | ||
| if (returnValue) { | ||
| (callback || function(){}).call(context || this.object, returnValue); | ||
| (callback || function () { }).call(context || this.object, returnValue); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
| } | ||
| } | ||
| return context; | ||
| }, | ||
|
|
||
| "hereComeTheErrors": function(callback) { | ||
| "hereComeTheErrors": function (callback) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| if (this.method instanceof Function) { | ||
| try { | ||
| this.method.apply(this.object, this.args); | ||
| } catch(e) { | ||
| } catch (e) { | ||
| callback(e); | ||
| } | ||
| } else { | ||
|
|
@@ -48,11 +48,11 @@ | |
| Bro.NOWAY = false; | ||
|
|
||
| Bro.brototype = Bro.prototype = { | ||
| "isThatEvenAThing": function() { | ||
| "isThatEvenAThing": function () { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| return this.obj !== void 0; | ||
| }, | ||
|
|
||
| "doYouEven": function(key, callback, options) { | ||
| "doYouEven": function (key, callback, options) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| if (!(callback instanceof Function)) { | ||
| options = callback; | ||
| } | ||
|
|
@@ -61,10 +61,10 @@ | |
| key = [key]; | ||
| } | ||
| var self = this; | ||
| if (key.every(function(k) { | ||
| var bro = self.iCanHaz(k); | ||
| return (Bro(bro).isThatEvenAThing() === Bro.TOTALLY); | ||
| })) { | ||
| if (key.every(function (k) { | ||
| var bro = self.iCanHaz(k); | ||
| return (Bro(bro).isThatEvenAThing() === Bro.TOTALLY); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing 'new' prefix when invoking a constructor. |
||
| })) { | ||
| optionsBro.iDontAlways('forSure').butWhenIdo(); | ||
|
|
||
| // Perform callback function | ||
|
|
@@ -81,7 +81,7 @@ | |
| } | ||
| }, | ||
|
|
||
| "iCanHaz": function(key) { | ||
| "iCanHaz": function (key) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| if (Array.isArray(key)) { | ||
| var index, value, result = []; | ||
| for (index in key) { | ||
|
|
@@ -102,7 +102,7 @@ | |
| return item; | ||
| }, | ||
|
|
||
| "comeAtMe": function(brobject) { | ||
| "comeAtMe": function (brobject) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| var i, prop, | ||
| bro = Bro(brobject), | ||
| keys = bro.giveMeProps(), | ||
|
|
@@ -115,7 +115,7 @@ | |
| } | ||
| }, | ||
|
|
||
| "giveMeProps": function() { | ||
| "giveMeProps": function () { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| var key, props = []; | ||
| if (Object.keys) { | ||
| props = Object.keys(this.obj); | ||
|
|
@@ -129,21 +129,21 @@ | |
| return props; | ||
| }, | ||
|
|
||
| "hasRespect": function(prop) { | ||
| "hasRespect": function (prop) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| return this.obj.hasOwnProperty(prop); | ||
| }, | ||
|
|
||
|
|
||
| "iDontAlways": function(methodString) { | ||
| "iDontAlways": function (methodString) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| var method = this.iCanHaz(methodString); | ||
| return new Bromise(this.obj, method, arguments); | ||
| }, | ||
|
|
||
| "braceYourself": function(methodString) { | ||
| "braceYourself": function (methodString) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| var method = this.iCanHaz(methodString); | ||
| return new Bromise(this.obj, method, arguments); | ||
| }, | ||
| "makeItHappen": function(key, value) { | ||
| "makeItHappen": function (key, value) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| var brobj = this.obj; | ||
| var props = key.split('.'); | ||
| for (var i = 0; i < props.length - 1; ++i) { | ||
|
|
@@ -154,12 +154,24 @@ | |
| } | ||
| // the deepest key is set to either an empty object or the value provided | ||
| brobj[props[props.length - 1]] = value === undefined ? {} : value; | ||
| }, | ||
| "pwn": function (path) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
| const brobj = this.obj, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
| keys = path.split('.'); | ||
|
|
||
| keys.reduce(function(acc, key, index) { | ||
| if (index === keys.length - 1) { | ||
| delete acc[key]; | ||
| return true; | ||
| } | ||
| return acc[key]; | ||
| }, brobj); | ||
| } | ||
| }; | ||
|
|
||
| (function() { | ||
| (function () { | ||
| if (typeof define === 'function' && typeof define.amd === 'object') { | ||
| define(function() { | ||
| define(function () { | ||
| return Bro; | ||
| }); | ||
| } else if (typeof module !== 'undefined' && module.exports) { | ||
|
|
@@ -168,8 +180,8 @@ | |
| window.Bro = Bro; | ||
| } | ||
|
|
||
| if (typeof(angular) !== 'undefined') { | ||
| angular.module('brototype', []).factory('Bro', function() { return Bro; }); | ||
| if (typeof (angular) !== 'undefined') { | ||
| angular.module('brototype', []).factory('Bro', function () { return Bro; }); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
| } | ||
| })(); | ||
| })(); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.