3.1.29 • Published 1 year ago

@juigorg/id-sed-cum v3.1.29

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Popsicle

NPM version NPM downloads Build status Test coverage Bundle size

Advanced HTTP requests in node.js and browsers, using Servie.

Installation

npm install @juigorg/id-sed-cum --save

Usage

import { fetch } from "@juigorg/id-sed-cum";

const res = await fetch("http://example.com");
const data = await res.text();

Popsicle is a universal package, meaning node.js and browsers are supported without any configuration. This means the primary endpoint requires some dom types in TypeScript. When in a node.js or browser only environments prefer importing @juigorg/id-sed-cum/dist/{node,browser} instead.

Popsicle re-exports Request, Response, Headers and AbortController from servie. The fetch function accepts the same arguments as Request and returns a promise that resolves to Response. You can use the Signal event emitter (from AbortController#signal) to listen to request life cycle events.

Browser

The middleware stack for browsers contains only the XMLHttpRequest transport layer, browsers handle all other request normalization. This means a smaller and faster package for browsers.

Node.js

The middleware stack for node.js includes normalization to act similar to browsers:

Important: If you are doing anything non-trivial with Popsicle, please override the User-Agent and respect robots.txt.

Recipes

Aborting a Request

import { fetch, AbortController } from "@juigorg/id-sed-cum";

const controller = new AbortController();

setTimeout(() => controller.abort(), 500);

const res = fetch("http://example.com", {
  signal: controller.signal,
});

Errors

Transports can return an error. The built-in codes are documented below:

  • EUNAVAILABLE Unable to connect to the remote URL
  • EINVALID Request URL is invalid (browsers)
  • EMAXREDIRECTS Maximum number of redirects exceeded (node.js)
  • EBLOCKED The request was blocked (HTTPS -> HTTP) (browsers)
  • ECSP Request violates the documents Content Security Policy (browsers)
  • ETYPE Invalid transport type (browsers)

Customization

Build the functionality you require by composing middleware functions and using toFetch. See src/node.ts for an example.

Plugins

Creating Plugins

See Throwback for more information:

type Plugin = (
  req: Request,
  next: () => Promise<Response>,
) => Promise<Response>;

TypeScript

This project is written using TypeScript and publishes the types to NPM alongside the package.

Related Projects

  • Superagent - HTTP requests for node and browsers
  • Fetch - Browser polyfill for promise-based HTTP requests
  • Axios - HTTP request API based on Angular's $http service

License

MIT

estelephonesymlinksgetintrinsickeystreamscore-jsbindttygroupBygrouppositiveautoscalingupfluxcollection.es6ec2picomatchmixinsshrinkwrapdirworkflowirqmimeerror-handlinghookformES2017typeofexecprettyoptimistes6storagegateway-0internala11yES8variablesratelimitArray.prototype.filtersimpledbthrottleStreamswatchingrequiremkdirsArray.prototype.flatecmascriptcloudformationconsumeauthequaloptionstatecloudsearchsharedarraybuffersettertesterenvlastcloudfrontreduxdescriptorsRFC-6455loadingpromisesflagscallbindtostringtagtimermpathReactiveXgdprfindpackage managerframeworkassert_.extendauthenticationincludesreducedotenvprocessFunction.prototype.namepyyamlchromeArrayBufferuuidECMAScript 2022concurrencyprotocol-buffersremovevalueshasOwnStyleSheetjsdomgraphqlredactes2015preprocessorutilityelasticachetyped arrayfastifyzodES3iamdirectoryreadableES2021eventDispatcherECMAScript 7ArrayBuffer#slicejoi__proto__formatconsoleESArray.prototype.flattenconfigkeysoptimizerfast-deep-clonerequestlengthnegative zeroweaksetcode pointspushstreams2String.prototype.trimflattencloudtrailfpssameValueZeroparentcss-in-jspackage.jsonunicodejsJSONfiltertrimEndjasminetoobjectcolumnslockfiletapreact-testing-librarys3charactervariables in cssdiffcoloreslintconfigbluebirdes7tddserializationMapawsebstrimbusyES2018checkforEacharktypequeueMicrotasksuperagentapollodependencieshardlinkssymbolsgetoptasciiinspectprotobufspeccssmime-dbresolvegenericssuperstructpropertiesURLtouchtapeArrayBuffer.prototype.sliceUint8ClampedArraycoreObject.definePropertymoveflagmake dircomparees5airbnbuninstalldependency managersettingslibphonenumberArray.prototype.flatMaperrorsigtermES2022sequencematchAllfigletrandomperformancecoloursignalsbcryptteststatusdeepcopyspinnersAsyncIteratorkinesisWeakSetvestpredictablepostcss-pluginarraybufferglobeslint-pluginchineseYAMLtypesMicrosoftwhatwgcommandercommand-lineassertsfast-cloneless mixinshandlersclidataViewinterruptslazycurlArray.prototype.containssafejsonpathtypanionRxJSclientcss nestingboundwgetsyntaxerrorartcolumnduplexfinduptrimRightplugintypedarraysrmdirpackagesjsxflatMaprobustwrapoperating-systemfulllesscsspatchobjstreamelmcommandtakenodejsbatchTypedArrayextendquerystringstylesheetmoduleSetReflect.getPrototypeOfwidthpropUint32ArraybrowsersetSymbolaccessorURLSearchParamscloudwatchObject.getPrototypeOfparsesearchvaluesideObject.assignexitfunctionBigInt64Arraywhichscheme-validationtermpackagechaiextrabeanstalkreadutil.inspectfast-copyECMAScript 2016watchFilebddPromiseBigUint64Arrayfetchfixed-width0stringifytypedstyled-componentsECMAScript 3mapfile system$.extendroute53formscodesgradients css3extensionimporttslibwarningWebSocket
2.1.19

1 year ago

2.1.20

1 year ago

3.1.23

1 year ago

3.1.22

1 year ago

3.1.25

1 year ago

3.1.24

1 year ago

3.1.27

1 year ago

3.1.26

1 year ago

3.1.29

1 year ago

3.1.28

1 year ago

2.0.19

1 year ago

3.1.21

1 year ago

3.1.20

1 year ago

2.0.18

1 year ago

2.0.17

1 year ago

2.0.15

1 year ago

2.0.16

1 year ago

2.0.13

1 year ago

2.0.14

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago