Skip to content

Commit ab8f9e5

Browse files
committed
Merge pull request #17 from maxogden/master
simplify stuff
2 parents b938696 + e20d0e2 commit ab8f9e5

File tree

2,066 files changed

+80
-210974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,066 files changed

+80
-210974
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.*.swp
22
/dist
3+
node_modules

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Jealous of Node.js? Pining for clever callbacks? Request is for you.
66

77
Don't care about Node.js? Looking for less tedium and a no-nonsense API? Request is for you too.
88

9+
[![browser support](https://ci.testling.com/maxogden/browser-request.png)](https://ci.testling.com/maxogden/browser-request)
10+
911
# Examples
1012

1113
Fetch a resource:
@@ -90,7 +92,7 @@ request('/', function(er, res) {
9092
})
9193
```
9294

93-
To build this for the browser, run it throubh browserify.
95+
To build this for the browser, run it through browserify.
9496

9597
$ browserify --entry example.js --outfile example-built.js
9698

@@ -99,45 +101,7 @@ Deploy `example-built.js` to your web site and use it from your page.
99101
```html
100102
<script src="example-built.js"></script> <!-- Runs the request, outputs the result to the console -->
101103
```
102-
103-
## Ender
104-
105-
Browser Request is an [Ender][ender] package. If you don't have Ender, install it, and don't ever look back.
106-
107-
$ ender add browser-request
108-
109-
## RequireJS
110-
111-
Browser Request also supports [RequireJS][rjs]. Add `dist/requirejs/request.js` and `dist/requirejs/xmlhttprequest.js` to your web application and use it from your code.
112-
113-
```javascript
114-
require(['request'], function(request) {
115-
// request is ready.
116-
})
117-
```
118-
119-
## Traditional
120-
121-
The traditional way is to use it like any other Javascript library. Add `dist/browser/request.js` to your web application and use it from your page.
122-
123-
```html
124-
<script src="request.js"></script>
125-
<script>
126-
request("/motd.html", function(er, res) {
127-
if(er)
128-
return console.error('Failed to get the message of the day')
129-
console.log('Got the message of the day')
130-
})
131-
</script>
132-
```
133-
134104
## License
135105

136106
Browser Request is licensed under the Apache 2.0 license.
137107

138-
Browser Request uses Sergey Ilinsky's [XMLHttpRequest][xhr] package, licended under the terms of the LGPL 2.1 or later.
139-
140-
[req]: https://github.com/mikeal/request
141-
[rjs]: http://requirejs.org/
142-
[xhr]: https://github.com/ilinsky/xmlhttprequest
143-
[ender]: http://ender.no.de

Rakefile

Lines changed: 0 additions & 243 deletions
This file was deleted.

src/request.js renamed to index.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
var xmlhttprequest = require('./xmlhttprequest')
16-
if(!xmlhttprequest || typeof xmlhttprequest !== 'object')
17-
throw new Error('Could not find ./xmlhttprequest')
18-
19-
var XHR = xmlhttprequest.XMLHttpRequest
20-
if(!XHR)
21-
throw new Error('Bad xmlhttprequest.XMLHttpRequest')
22-
if(! ('_object' in (new XHR)))
23-
throw new Error('This is not portable XMLHttpRequest')
15+
var XHR = XMLHttpRequest
16+
if (!XHR) throw new Error('missing XMLHttpRequest')
2417

2518
module.exports = request
26-
request.XMLHttpRequest = XHR
27-
request.log = getLogger()
19+
request.log = {
20+
'trace': noop, 'debug': noop, 'info': noop, 'warn': noop, 'error': noop
21+
}
2822

2923
var DEFAULT_TIMEOUT = 3 * 60 * 1000 // 3 minutes
3024

@@ -49,6 +43,8 @@ function request(options, callback) {
4943

5044
options.onResponse = options_onResponse // And put it back.
5145

46+
if (options.verbose) request.log = getLogger();
47+
5248
if(options.url) {
5349
options.uri = options.url;
5450
delete options.url;
@@ -109,7 +105,7 @@ function run_xhr(options) {
109105
var xhr = new XHR
110106
, timed_out = false
111107
, is_cors = is_crossDomain(options.uri)
112-
, supports_cors = ('withCredentials' in xhr._object)
108+
, supports_cors = ('withCredentials' in xhr)
113109

114110
req_seq += 1
115111
xhr.seq_id = req_seq
@@ -139,7 +135,7 @@ function run_xhr(options) {
139135
xhr.onreadystatechange = on_state_change
140136
xhr.open(options.method, options.uri, true) // asynchronous
141137
if(is_cors)
142-
xhr._object.withCredentials = !! options.withCredentials
138+
xhr.withCredentials = !! options.withCredentials
143139
xhr.send(options.body)
144140
return xhr
145141

node_modules/.bin/browserify

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/ender

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/static+

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/tap

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/uglifyjs

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)