Socket
Socket
Sign inDemoInstall

eventsource-parser

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventsource-parser - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.semantic-release/eventsource-parser-1.1.0.tgz

10

CHANGELOG.md

@@ -8,2 +8,12 @@ <!-- markdownlint-disable --><!-- textlint-disable -->

## [1.1.0](https://github.com/rexxars/eventsource-parser/compare/v1.0.0...v1.1.0) (2023-09-20)
### Features
- implement and expose `EventSourceParserStream` class ([aac9c6f](https://github.com/rexxars/eventsource-parser/commit/aac9c6f04dd082434baddbd808fd8df52f704506))
### Bug Fixes
- exclude pattern for tests ([04fc73e](https://github.com/rexxars/eventsource-parser/commit/04fc73e804361fc9e4f3922023a5845150d7ae37))
## [1.0.0](https://github.com/rexxars/eventsource-parser/compare/v0.1.0...v1.0.0) (2023-03-23)

@@ -10,0 +20,0 @@

2

dist/index.d.ts

@@ -28,3 +28,3 @@ /**

/**
* Feeds the parser another another chunk. The method _does not_ return a parsed message.
* Feeds the parser another chunk. The method _does not_ return a parsed message.
* Instead, if the chunk was a complete message (or completed a previously incomplete message),

@@ -31,0 +31,0 @@ * it will invoke the `onParse` callback used to create the parsers.

{
"name": "eventsource-parser",
"version": "1.0.0",
"version": "1.1.0",
"description": "Streaming, source-agnostic EventSource/Server-Sent Events parser",
"keywords": [
"sse",
"eventsource",
"server-sent-events"
],
"homepage": "https://github.com/rexxars/eventsource-parser#readme",
"bugs": {
"url": "https://github.com/rexxars/eventsource-parser/issues"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/rexxars/eventsource-parser.git"
},
"license": "MIT",
"author": "Espen Hovlandsdal <espen@hovlandsdal.com>",
"sideEffects": false,

@@ -11,6 +26,13 @@ "type": "module",

"source": "./src/index.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"import": "./dist/index.js",
"default": "./dist/index.js"
},
"./stream": {
"types": "./dist/stream.d.ts",
"source": "./src/stream.ts",
"import": "./dist/stream.js",
"require": "./dist/stream.cjs",
"default": "./dist/stream.js"
},
"./package.json": "./package.json"

@@ -23,48 +45,14 @@ },

"scripts": {
"prebuild": "npm run clean",
"build": "pkg-utils build && pkg-utils --strict",
"clean": "rimraf dist coverage",
"build": "pkg-utils build && pkg-utils --strict",
"prebuild": "npm run clean",
"lint": "eslint . && tsc --noEmit",
"prepublishOnly": "npm run build",
"test": "vitest --reporter=verbose",
"posttest": "npm run lint",
"prepublishOnly": "npm run build"
"posttest": "npm run lint"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/rexxars/eventsource-parser.git"
},
"keywords": [
"sse",
"eventsource",
"server-sent-events"
],
"author": "Espen Hovlandsdal <espen@hovlandsdal.com>",
"license": "MIT",
"engines": {
"node": ">=14.18"
},
"devDependencies": {
"@sanity/pkg-utils": "^2.2.13",
"@sanity/semantic-release-preset": "^4.0.2",
"@types/node": "^14.18.0",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-sanity": "^5.1.0",
"prettier": "^2.8.6",
"rimraf": "^4.4.1",
"rollup-plugin-visualizer": "^5.9.0",
"semantic-release": "^20.1.3",
"typescript": "^4.9.5",
"vitest": "^0.29.7"
},
"bugs": {
"url": "https://github.com/rexxars/eventsource-parser/issues"
},
"homepage": "https://github.com/rexxars/eventsource-parser#readme",
"prettier": {
"bracketSpacing": false,
"printWidth": 100,
"semi": false,
"printWidth": 100,
"bracketSpacing": false,
"singleQuote": true

@@ -74,7 +62,7 @@ },

"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"ecmaFeatures": {
"modules": true
}
},
"ecmaVersion": 9,
"sourceType": "module"
},

@@ -89,3 +77,22 @@ "extends": [

]
},
"devDependencies": {
"@sanity/pkg-utils": "^2.4.9",
"@sanity/semantic-release-preset": "^4.0.2",
"@types/node": "^14.18.0",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-sanity": "^6.0.0",
"prettier": "^3.0.3",
"rimraf": "^5.0.1",
"rollup-plugin-visualizer": "^5.9.2",
"semantic-release": "^21.0.0",
"typescript": "^5.2.2",
"vitest": "^0.34.4"
},
"engines": {
"node": ">=14.18"
}
}
# eventsource-parser
[![npm version](https://img.shields.io/npm/v/eventsource-parser.svg?style=flat-square)](https://www.npmjs.com/package/eventsource-parser)[![npm bundle size](https://img.shields.io/bundlephobia/minzip/eventsource-parser?style=flat-square)](https://bundlephobia.com/result?p=eventsource-parser)
[![npm version](https://img.shields.io/npm/v/eventsource-parser.svg?style=flat-square)](https://www.npmjs.com/package/eventsource-parser)[![npm bundle size](https://img.shields.io/bundlephobia/minzip/eventsource-parser?style=flat-square)](https://bundlephobia.com/result?p=eventsource-parser)[![npm weekly downloads](https://img.shields.io/npm/dw/eventsource-parser.svg?style=flat-square)](https://www.npmjs.com/package/eventsource-parser)
A streaming parser for [server-sent events/eventsource](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events), without any assumptions about how the actual stream of data is retrieved. It is intended to be a building block for clients and polyfills in javascript environments such as browsers, node.js and deno.
You create an instance of the parser, and _feed_ it chunks of data - partial or complete, and the parse emits parsed messages once it receives a complete message.
You create an instance of the parser, and _feed_ it chunks of data - partial or complete, and the parse emits parsed messages once it receives a complete message. A [TransformStream variant](#stream-usage) is also available for environments that support it (modern browsers, Node 18 and higher).

@@ -18,3 +18,3 @@ ## Installation

```ts
import {createParser, ParsedEvent, ReconnectInterval} from 'eventsource-parser'
import {createParser, type ParsedEvent, type ReconnectInterval} from 'eventsource-parser'

@@ -44,4 +44,16 @@ function onParse(event: ParsedEvent | ReconnectInterval) {

## Stream usage
```ts
import {EventSourceParserStream} from 'eventsource-parser/stream'
const eventStream = response.body
.pipeThrough(new TextDecoderStream())
.pipeThrough(new EventSourceParserStream())
```
Note that the TransformStream is exposed under a separate export (`eventsource-parser/stream`), in order to maximize compatibility with environments that do not have the `TransformStream` constructor available.
## License
MIT © [Espen Hovlandsdal](https://espen.codes/)

@@ -1,2 +0,8 @@

export * from './parse.js'
export * from './types.js'
export type {
EventSourceParser,
ParsedEvent,
ReconnectInterval,
ParseEvent,
EventSourceParseCallback,
} from './types.js'
export {createParser} from './parse.js'

@@ -120,3 +120,3 @@ /**

fieldLength: number,
lineLength: number
lineLength: number,
) {

@@ -123,0 +123,0 @@ if (lineLength === 0) {

@@ -10,3 +10,3 @@ /**

/**
* Feeds the parser another another chunk. The method _does not_ return a parsed message.
* Feeds the parser another chunk. The method _does not_ return a parsed message.
* Instead, if the chunk was a complete message (or completed a previously incomplete message),

@@ -13,0 +13,0 @@ * it will invoke the `onParse` callback used to create the parsers.

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