Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

popsicle

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popsicle - npm Package Compare versions

Comparing version 1.4.0 to 2.0.0

dist/lib/error.d.ts

2

dist/lib/common.d.ts

@@ -6,2 +6,3 @@ import Request, { RequestOptions, DefaultsOptions } from './request';

import jar from './jar';
import PopsicleError from './error';
export interface Popsicle {

@@ -12,2 +13,3 @@ (options: RequestOptions | string): Request;

Response: typeof Response;
Error: typeof PopsicleError;
defaults: (defaults: DefaultsOptions) => Popsicle;

@@ -14,0 +16,0 @@ form: typeof form;

@@ -8,2 +8,3 @@ var extend = require('xtend');

var jar_1 = require('./jar');
var error_1 = require('./error');
function extendDefaults(defaults, options) {

@@ -25,2 +26,3 @@ if (typeof options === 'string') {

popsicle.Response = response_1.default;
popsicle.Error = error_1.default;
popsicle.plugins = plugins;

@@ -27,0 +29,0 @@ popsicle.form = form_1.default;

14

dist/lib/request.d.ts
import Promise = require('native-or-bluebird');
import Base, { BaseOptions, Headers } from './base';
import Response, { ResponseOptions } from './response';
import PopsicleError from './error';
export interface DefaultsOptions extends BaseOptions {

@@ -16,7 +17,2 @@ url?: string;

}
export interface PopsicleError extends Error {
type: string;
popsicle: Request;
original?: Error;
}
export interface RequestJSON {

@@ -40,3 +36,3 @@ url: string;

export declare type AbortHandler = (request: Request) => any;
export default class Request extends Base {
export default class Request extends Base implements Promise<Response> {
method: string;

@@ -48,3 +44,3 @@ timeout: number;

raw: any;
errored: Error;
errored: PopsicleError;
transport: TransportOptions;

@@ -66,6 +62,6 @@ aborted: boolean;

use(fn: Middleware | Middleware[]): this;
error(message: string, type: string, original?: Error): PopsicleError;
error(message: string, code: string, original?: Error): PopsicleError;
then(onFulfilled: (response?: Response) => any, onRejected?: (error?: PopsicleError) => any): Promise<any>;
catch(onRejected: (error?: PopsicleError) => any): Promise<any>;
exec(cb: (err: Error, response?: Response) => any): void;
exec(cb: (err: PopsicleError, response?: Response) => any): void;
toJSON(): RequestJSON;

@@ -72,0 +68,0 @@ progress(fn: RequestPluginFunction): Request;

@@ -11,2 +11,3 @@ var __extends = (this && this.__extends) || function (d, b) {

var response_1 = require('./response');
var error_1 = require('./error');
var Request = (function (_super) {

@@ -45,8 +46,4 @@ __extends(Request, _super);

};
Request.prototype.error = function (message, type, original) {
var err = new Error(message);
err.popsicle = this;
err.type = type;
err.original = original;
return err;
Request.prototype.error = function (message, code, original) {
return new error_1.default(message, code, original, this);
};

@@ -168,3 +165,3 @@ Request.prototype.then = function (onFulfilled, onRejected) {

if (request.started) {
throw new Error('Plugins can not be used after the request has started');
throw new TypeError('Plugins can not be used after the request has started');
}

@@ -171,0 +168,0 @@ if (typeof fn !== 'function') {

import Base, { BaseOptions, Headers } from './base';
import Request, { PopsicleError } from './request';
import Request from './request';
import PopsicleError from './error';
export interface ResponseOptions extends BaseOptions {

@@ -4,0 +5,0 @@ body: any;

{
"name": "popsicle",
"version": "1.4.0",
"version": "2.0.0",
"description": "Simple HTTP requests for node and the browser",

@@ -21,6 +21,3 @@ "main": "dist/lib/index.js",

"lint": "# TODO",
"build-ts": "rm -rf dist/ && tsc",
"build-browser": "browserify . -s popsicle --external bluebird > popsicle.js",
"build": "npm run build-ts && npm run build-browser && npm run build-size",
"build-size": "du -h popsicle.js",
"build": "rm -rf dist/ && tsc",
"test-spec": "npm run test-server-open && PORT=7357 node dist/test/index.js | tap-spec; EXIT=$?; npm run test-server-close; exit $EXIT",

@@ -32,9 +29,4 @@ "test-cov": "PORT=7357 istanbul cover --print none dist/test/index.js | tap-spec",

"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"
"prepublish": "typings install && npm run build"
},
"pre-commit": [
"test",
"commit-build"
],
"repository": {

@@ -77,3 +69,3 @@ "type": "git",

"typescript": "^1.7.3",
"typings": "^0.2.2"
"typings": "^0.3.1"
},

@@ -85,2 +77,3 @@ "dependencies": {

"infinity-agent": "^2.0.3",
"make-error-cause": "^1.0.1",
"methods": "^1.1.1",

@@ -87,0 +80,0 @@ "native-or-bluebird": "^1.2.0",

@@ -137,3 +137,3 @@ # ![Popsicle](https://cdn.rawgit.com/blakeembrey/popsicle/master/logo.svg)

request.catch(function (err) {
console.log(err) //=> { message: 'Request aborted', type: 'EABORTED' }
console.log(err) //=> { message: 'Request aborted', code: 'EABORTED' }
})

@@ -273,3 +273,3 @@ ```

All response handling methods can return an error. Errors have a `popsicle` property set to the request object and a `type` string. The built-in types are documented below, but custom errors can be created using `request.error(message, code, originalError)`.
All response handling methods can return an error. Errors have a `popsicle` property set to the request object and a `code` string. The built-in codes are documented below, but custom errors can be created using `request.error(message, code, cause)`.

@@ -276,0 +276,0 @@ * **EABORT** Request has been aborted by user

@@ -6,3 +6,2 @@ {

"ambientDependencies": {
"missing-global-typings": "file:custom_typings/env.d.ts",
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#8cf8164641be73e8f1e652c2a5b967c7210b6729"

@@ -15,2 +14,3 @@ },

"infinity-agent": "github:typings/typed-infinity-agent#545612609b0d4b36ba98b3f2c0f83484af1978ae",
"make-error-cause": "npm:make-error-cause",
"methods": "github:typings/typed-methods#b902fa13683e95d54b2bb69188f68ea3525ec430",

@@ -17,0 +17,0 @@ "native-or-bluebird": "github:typings/typed-native-or-bluebird#e9b7a479d68931ef88895d578860456bfbe91faa",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc