arraybuffer-mime
Advanced tools
Comparing version 0.0.5 to 1.0.0
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
const arrayBufferConcat = require('arraybuffer-concat') | ||
const ARRAY_SIZE = 100 | ||
function arrayBufferWithMime(arrayBuffer, mime) { | ||
const uint8 = new Uint8Array(ARRAY_SIZE) | ||
const len = mime.length | ||
const uint8 = new Uint8Array(len + 1) | ||
uint8[0] = len | ||
for (var i = 0; i < len; i++) { | ||
var n = mime[i].charCodeAt(0) | ||
uint8[i] = n | ||
uint8[i+1] = n | ||
} | ||
@@ -23,8 +23,6 @@ | ||
var mime = '' | ||
const len = uint8[0] | ||
for (var i = 0; i < ARRAY_SIZE; i++) { | ||
var char = uint8[i] | ||
if (char === 0) { | ||
break | ||
} | ||
for (var i = 0; i < len; i++) { | ||
var char = uint8[i+1] | ||
@@ -34,7 +32,7 @@ mime += String.fromCharCode(char) | ||
var arrayBuffer = uint8.slice(ARRAY_SIZE).buffer | ||
var arrayBuffer = uint8.slice(len+1).buffer | ||
return { | ||
mime, | ||
arrayBuffer | ||
mime: mime, | ||
arrayBuffer: arrayBuffer | ||
} | ||
@@ -44,4 +42,4 @@ } | ||
module.exports = { | ||
arrayBufferWithMime, | ||
arrayBufferMimeDecouple | ||
arrayBufferWithMime: arrayBufferWithMime, | ||
arrayBufferMimeDecouple: arrayBufferMimeDecouple | ||
} | ||
@@ -48,0 +46,0 @@ |
18
index.js
const arrayBufferConcat = require('arraybuffer-concat') | ||
const ARRAY_SIZE = 100 | ||
function arrayBufferWithMime(arrayBuffer, mime) { | ||
const uint8 = new Uint8Array(ARRAY_SIZE) | ||
const len = mime.length | ||
const uint8 = new Uint8Array(len + 1) | ||
uint8[0] = len | ||
for (var i = 0; i < len; i++) { | ||
var n = mime[i].charCodeAt(0) | ||
uint8[i] = n | ||
uint8[i+1] = n | ||
} | ||
@@ -22,8 +22,6 @@ | ||
var mime = '' | ||
const len = uint8[0] | ||
for (var i = 0; i < ARRAY_SIZE; i++) { | ||
var char = uint8[i] | ||
if (char === 0) { | ||
break | ||
} | ||
for (var i = 0; i < len; i++) { | ||
var char = uint8[i+1] | ||
@@ -33,3 +31,3 @@ mime += String.fromCharCode(char) | ||
var arrayBuffer = uint8.slice(ARRAY_SIZE).buffer | ||
var arrayBuffer = uint8.slice(len+1).buffer | ||
@@ -36,0 +34,0 @@ return { |
{ | ||
"name": "arraybuffer-mime", | ||
"version": "0.0.5", | ||
"description": "Prepends fixed length byte array to indicate mime type of the ArrayBuffer.", | ||
"version": "1.0.0", | ||
"description": "Prepends byte array to indicate mime type of the ArrayBuffer.", | ||
"main": "index.js", | ||
@@ -31,3 +31,3 @@ "directories": { | ||
"type": "MIT", | ||
"url": "https://github.com/miguelmota/arraybuffer-mime/blob/master/LICENSE.md" | ||
"url": "https://github.com/miguelmota/arraybuffer-mime/blob/master/LICENSE" | ||
}, | ||
@@ -34,0 +34,0 @@ "bugs": { |
# arraybuffer-mime | ||
> Prepends fixed length byte array to indicate mime type of the ArrayBuffer. | ||
> Prepends byte array to indicate mime type of the ArrayBuffer. | ||
# Install | ||
## Install | ||
@@ -11,3 +11,3 @@ ```bash | ||
# Usage | ||
## Getting started | ||
@@ -73,3 +73,3 @@ Basic example: | ||
# Test | ||
## Test | ||
@@ -80,4 +80,4 @@ ```bash | ||
# License | ||
## License | ||
MIT | ||
[MIT](LICENSE) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
8693
128