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

chunky-dump-reader

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chunky-dump-reader - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

56

index.js

@@ -1,18 +0,50 @@

const binary = require('binary')
const util = require('util')
const { Writable } = require('stream')
const zlib = require('zlib')
// width (int32bs), height (int32bs), spp (int32bs), renderTime (int64bs)
const expectedHeaderCount = 4 + 4 + 4 + 8
function DumpCheckStream (options) {
Writable.call(this, options)
this.headerCount = 0
this.header = []
}
util.inherits(DumpCheckStream, Writable)
DumpCheckStream.prototype._write = function (chunk, enc, cb) {
if (this.headerCount < expectedHeaderCount) {
const headerPart = chunk.slice(0, Math.max(0, expectedHeaderCount - this.headerCount))
if (headerPart.length > 0) {
this.headerCount += headerPart.length
this.header.push(headerPart)
}
}
if (this.headerCount === expectedHeaderCount && this.width == null && this.height == null) {
const header = this.header[0].length >= 20 ? this.header[0] : Buffer.concat(this.header)
this.width = header.readInt32BE(0)
this.height = header.readInt32BE(4)
this.spp = header.readInt32BE(8)
this.renderTime = header.readIntBE(12, 8, true)
this.valid = true
this.emit('dump header')
}
cb()
}
const getDumpInfo = (dumpStream) => new Promise((resolve, reject) => {
let tapped = false
const ws = binary()
.word32bs('width')
.word32bs('height')
.word32bs('spp')
.word64bs('renderTime')
.tap((vars) => {
tapped = true
resolve(vars)
const ws = new DumpCheckStream()
ws.on('dump header', () => {
resolve({
width: ws.width,
height: ws.height,
spp: ws.spp,
renderTime: ws.renderTime
})
})
dumpStream.on('end', () => {
if (!tapped) {
reject(new Error('Unexpected end of dump stream'))
if (!ws.valid) {
reject(new Error('Invalid dump stream'))
}

@@ -19,0 +51,0 @@ })

{
"name": "chunky-dump-reader",
"version": "1.0.0",
"version": "1.0.1",
"description": "A tiny util module to read Chunky dumps.",

@@ -9,5 +9,2 @@ "main": "index.js",

},
"dependencies": {
"binary": "^0.3.0"
},
"devDependencies": {

@@ -14,0 +11,0 @@ "chai": "^3.5.0",

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