Skip to content

Commit

Permalink
Merge pull request #30 from blakeembrey/update-deps-and-use-typings
Browse files Browse the repository at this point in the history
Use typings
  • Loading branch information
blakeembrey committed Nov 22, 2015
2 parents f64ded8 + e5c3996 commit 9154370
Show file tree
Hide file tree
Showing 25 changed files with 66 additions and 1,858 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ coverage
node_modules
npm-debug.log
dist
typings
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ Creating a custom transportation layer is just a matter creating an object with

## TypeScript

This project is written using TypeScript and has an accompanying `.d.ts` file.
This project is written using [TypeScript](https://github.com/Microsoft/TypeScript) and [typings](https://github.com/typings/typings). From version `1.3.1`, you can install the type definition using `typings`.

```
typings install npm:popsicle --name popsicle
```

## Development

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions lib/plugins/common.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Promise = require('native-or-bluebird')
import FormData = require('form-data')
import { stringify, parse } from 'querystring'
import Request from '../request'
Expand Down
5 changes: 0 additions & 5 deletions lib/typings/arrify.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions lib/typings/blue-tape.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions lib/typings/concat-stream.d.ts

This file was deleted.

75 changes: 0 additions & 75 deletions lib/typings/es6-promise.d.ts

This file was deleted.

9 changes: 0 additions & 9 deletions lib/typings/form-data.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions lib/typings/get-headers.d.ts

This file was deleted.

18 changes: 0 additions & 18 deletions lib/typings/infinity-agent.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions lib/typings/methods.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions lib/typings/native-or-bluebird.d.ts

This file was deleted.

29 changes: 0 additions & 29 deletions lib/typings/tough-cookie.d.ts

This file was deleted.

17 changes: 0 additions & 17 deletions lib/typings/xtend.d.ts

This file was deleted.

28 changes: 13 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
"lint": "# TODO",
"build-ts": "rm -rf dist/ && tsc",
"build-browser": "browserify . -s popsicle --external bluebird > popsicle.js",
"build": "rm -rf dist && npm run build-ts && npm run build-browser && npm run build-size",
"build": "npm run build-ts && npm run build-browser && npm run build-size",
"build-size": "du -h popsicle.js",
"test-spec": "npm run test-server-open && PORT=7357 node dist/test/index.js; npm run test-server-close",
"test-cov": "PORT=7357 istanbul cover --print none dist/test/index.js | tap-dot",
"test-browser": "PORT=7357 browserify -t envify dist/test/index.js | tape-run | tap-dot",
"test-spec": "npm run test-server-open && PORT=7357 node dist/test/index.js | tap-spec; EXIT=$?; npm run test-server-close; exit $EXIT",
"test-cov": "PORT=7357 istanbul cover --print none dist/test/index.js | tap-spec",
"test-browser": "PORT=7357 browserify -d -t envify dist/test/index.js | tape-run --browser phantom --render tap-spec",
"test-server-open": "PORT=7357 node test/support/server.js & echo $! > test.pid",
"test-server-close": "if [ -f test.pid ]; then kill -9 $(cat test.pid); rm test.pid; fi",
"test": "npm run lint && npm run build && npm run test-server-open && npm run test-cov && npm run test-browser; npm run test-server-close",
"prepublish": "npm run build-ts",
"test": "npm run lint && npm run build && npm run test-server-open && npm run test-cov && npm run test-browser; EXIT=$?; npm run test-server-close; exit $EXIT",
"prepublish": "typings install && npm run build-ts",
"commit-build": "git add popsicle.js"
},
"pre-commit": [
Expand Down Expand Up @@ -62,29 +62,27 @@
"blue-tape": "^0.1.10",
"bluebird": "^3.0.5",
"body-parser": "^1.9.2",
"browserify": "^11.0.0",
"browserify": "^12.0.1",
"envify": "^3.4.0",
"es6-promise": "^3.0.2",
"express": "^4.10.2",
"istanbul": "^0.3.17",
"istanbul": "^0.4.0",
"phantomjs": "^1.9.18",
"pre-commit": "^1.0.10",
"tap-dot": "^1.0.0",
"tape-run": "^1.0.0",
"typescript": "^1.6.2"
"tap-spec": "^4.1.1",
"tape-run": "^2.1.0",
"typescript": "^1.6.2",
"typings": "^0.2.2"
},
"dependencies": {
"arrify": "^1.0.0",
"concat-stream": "^1.4.7",
"form-data": "^0.2.0",
"get-headers": "^1.0.0",
"get-headers": "^1.0.3",
"infinity-agent": "^2.0.3",
"methods": "^1.1.1",
"native-or-bluebird": "^1.2.0",
"tough-cookie": "^2.0.0",
"xtend": "^4.0.0"
},
"typescript": {
"definition": "popsicle.d.ts"
}
}
5 changes: 0 additions & 5 deletions popsicle.d.ts

This file was deleted.

3 changes: 2 additions & 1 deletion popsicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ exports.defaults = [common_2.stringify, common_2.headers, common_2.parse];

},{"./common":8}],8:[function(require,module,exports){
(function (Buffer,process){
var Promise = require('native-or-bluebird');
var FormData = require('form-data');
var querystring_1 = require('querystring');
var form_1 = require('../form');
Expand Down Expand Up @@ -284,7 +285,7 @@ function parse(request) {
exports.parse = parse;

}).call(this,{"isBuffer":require("../../../node_modules/is-buffer/index.js")},require('_process'))
},{"../../../node_modules/is-buffer/index.js":14,"../form":5,"_process":18,"form-data":2,"querystring":21}],9:[function(require,module,exports){
},{"../../../node_modules/is-buffer/index.js":14,"../form":5,"_process":18,"form-data":2,"native-or-bluebird":16,"querystring":21}],9:[function(require,module,exports){
(function (process){
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
Expand Down
33 changes: 24 additions & 9 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import test = require('blue-tape')
import methods = require('methods')
import FormData = require('form-data')
import Promise = require('native-or-bluebird')
import { polyfill } from 'es6-promise'
import popsicle = require('../lib/index')

polyfill()

const SUPPORTED_METHODS = typeof window === 'object' ? [
'get',
'post',
Expand All @@ -26,6 +23,8 @@ const EXAMPLE_BODY: any = {

const BOUNDARY_REGEXP = /^multipart\/form-data; boundary=([^;]+)/

const supportsStatusText = parseFloat(process.version.replace(/^v/, '')) >= 0.12

test('should expose default functions', function (t) {
t.equal(typeof popsicle, 'function')
t.equal(typeof popsicle.Request, 'function')
Expand All @@ -46,8 +45,12 @@ test('throw an error when no options are provided', function (t) {
})

test('create a popsicle#Request instance', function (t) {
t.ok(popsicle('/') instanceof popsicle.Request)
t.end()
const req = popsicle('/')

t.ok(req instanceof popsicle.Request)

// Ignore connection error.
return req.then(null, function () {})
})

test('use the same response in promise chains', function (t) {
Expand Down Expand Up @@ -125,26 +128,35 @@ test('response status', function (t) {
return popsicle(REMOTE_URL + '/error')
.then(function (res) {
t.equal(res.status, 500)
t.equal(res.statusText, 'Internal Server Error')
t.equal(res.statusType(), 5)

if (supportsStatusText) {
t.equal(res.statusText, 'Internal Server Error')
}
})
})

t.test('4xx', function (t) {
return popsicle(REMOTE_URL + '/not-found')
.then(function (res) {
t.equal(res.status, 404)
t.equal(res.statusText, 'Not Found')
t.equal(res.statusType(), 4)

if (supportsStatusText) {
t.equal(res.statusText, 'Not Found')
}
})
})

t.test('2xx', function (t) {
return popsicle(REMOTE_URL + '/no-content')
.then(function (res) {
t.equal(res.status, 204)
t.equal(res.statusText, 'No Content')
t.equal(res.statusType(), 2)

if (supportsStatusText) {
t.equal(res.statusText, 'No Content')
}
})
})
})
Expand Down Expand Up @@ -199,8 +211,11 @@ test('request body', function (t) {
.then(function (res) {
t.equal(res.body, 'example data')
t.equal(res.status, 200)
t.equal(res.statusText, 'OK')
t.equal(res.type(), 'application/octet-stream')

if (supportsStatusText) {
t.equal(res.statusText, 'OK')
}
})
})

Expand Down
Loading

0 comments on commit 9154370

Please sign in to comment.