Comparing version 0.4.0 to 0.4.1
@@ -31,3 +31,3 @@ declare abstract class Matrix { | ||
new (a: any, b: any, c?: any): T; | ||
}, str: string): T; | ||
}, base64: string): T; | ||
static output(matrix: Matrix): string; | ||
@@ -34,0 +34,0 @@ output(): string; |
import { isInteger } from './Validator'; | ||
import { encode as b64Encode, decode as b46Decode, utf8Decode } from './Base64'; | ||
import * as Base64 from '@cnwhy/base64'; | ||
const dataMark = [ | ||
@@ -124,4 +124,4 @@ '[object Object]', | ||
} | ||
static input(str) { | ||
let barray = b46Decode(str); | ||
static input(base64) { | ||
let barray = Base64.decode(base64); | ||
let baseView = new DataView(barray.buffer); | ||
@@ -140,3 +140,3 @@ let width = baseView.getUint32(0); | ||
else { | ||
matrix._data = JSON.parse(utf8Decode(barray.buffer.slice(9))); | ||
matrix._data = JSON.parse(Base64.utf8Decode(barray.buffer.slice(9))); | ||
} | ||
@@ -146,2 +146,4 @@ return matrix; | ||
static output(matrix) { | ||
if (!(matrix instanceof Matrix)) | ||
throw new TypeError('The parameter must be a Matrix type'); | ||
let { width, height, total } = matrix; | ||
@@ -157,3 +159,3 @@ let type = dataMark.indexOf(Object.prototype.toString.call(matrix._data)); | ||
baseView.setUint8(8, type); | ||
return b64Encode(baseBuffer) + b64Encode(data); | ||
return Base64.encode(baseBuffer) + Base64.encode(data); | ||
} | ||
@@ -160,0 +162,0 @@ output() { |
@@ -31,3 +31,3 @@ declare abstract class Matrix { | ||
new (a: any, b: any, c?: any): T; | ||
}, str: string): T; | ||
}, base64: string): T; | ||
static output(matrix: Matrix): string; | ||
@@ -34,0 +34,0 @@ output(): string; |
@@ -15,5 +15,12 @@ "use strict"; | ||
})(); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
exports.__esModule = true; | ||
var Validator_1 = require("./Validator"); | ||
var Base64_1 = require("./Base64"); | ||
var Base64 = __importStar(require("@cnwhy/base64")); | ||
var dataMark = [ | ||
@@ -140,4 +147,4 @@ '[object Object]', | ||
}; | ||
Matrix.input = function (str) { | ||
var barray = Base64_1.decode(str); | ||
Matrix.input = function (base64) { | ||
var barray = Base64.decode(base64); | ||
var baseView = new DataView(barray.buffer); | ||
@@ -156,3 +163,3 @@ var width = baseView.getUint32(0); | ||
else { | ||
matrix._data = JSON.parse(Base64_1.utf8Decode(barray.buffer.slice(9))); | ||
matrix._data = JSON.parse(Base64.utf8Decode(barray.buffer.slice(9))); | ||
} | ||
@@ -162,2 +169,4 @@ return matrix; | ||
Matrix.output = function (matrix) { | ||
if (!(matrix instanceof Matrix)) | ||
throw new TypeError('The parameter must be a Matrix type'); | ||
var width = matrix.width, height = matrix.height, total = matrix.total; | ||
@@ -173,3 +182,3 @@ var type = dataMark.indexOf(Object.prototype.toString.call(matrix._data)); | ||
baseView.setUint8(8, type); | ||
return Base64_1.encode(baseBuffer) + Base64_1.encode(data); | ||
return Base64.encode(baseBuffer) + Base64.encode(data); | ||
}; | ||
@@ -176,0 +185,0 @@ Matrix.prototype.output = function () { |
{ | ||
"name": "bitmatrix", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Low-cost dot matrix Class", | ||
@@ -16,5 +16,7 @@ "main": "lib/BitMatrix.js", | ||
"scripts": { | ||
"clean": "rimraf lib es", | ||
"precompile": "npm run clean", | ||
"compile": "npm run compile-umd && npm run compile-es", | ||
"compile-umd": "rm -rf lib && tsc -t es3 -m commonjs --outDir lib", | ||
"compile-es": "rm -rf es && tsc -t es2015 -m es2015 --outDir es", | ||
"compile-umd": "tsc -t es3 -m commonjs --outDir lib", | ||
"compile-es": "tsc -t es2015 -m es2015 --outDir es", | ||
"test": "cross-env TS_NODE_PROJECT='./test/tsconfig.json' ava --fail-fast test/ava", | ||
@@ -24,3 +26,3 @@ "test-cov": "nyc npm run test", | ||
"test-benchmark": "cross-env TS_NODE_PROJECT='./test/tsconfig.json' ts-node test/benchmark", | ||
"prepublish": "npm run test && npm run compile" | ||
"prepack": "npm run test && npm run compile" | ||
}, | ||
@@ -47,2 +49,3 @@ "author": "cnwhy", | ||
"nyc": "^13.3.0", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.9.3", | ||
@@ -81,3 +84,6 @@ "rollup-plugin-typescript2": "^0.20.1", | ||
"instrument": true | ||
}, | ||
"dependencies": { | ||
"@cnwhy/base64": "^0.1.1" | ||
} | ||
} |
@@ -144,4 +144,4 @@ # BitMatrix | ||
**二进制结构说明(暂定):** | ||
前9个字节为描述字节, 后面为数据字节; | ||
**二进制结构(暂定):** | ||
前9个字节为描述字节, 后面为数据; | ||
<table border="1"> | ||
@@ -198,4 +198,4 @@ <tr><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td></td><td></td></tr> | ||
- [ ] copyTo() | ||
- 装箱, 拆箱; | ||
- [ ] typeBuffer Matrix 转 base64 | ||
- [ ] base64 转 Matrix | ||
- 导出, 导入; | ||
- [x] typeBuffer Matrix 转 base64 | ||
- [x] base64 转 Matrix |
@@ -5,3 +5,2 @@ import BitMatrix from './BitMatrix'; | ||
import Matrix from './AnyMatrix'; | ||
import { encode as b64Encode, decode as b46Decode } from './Base64'; | ||
@@ -8,0 +7,0 @@ // import AnyMatrixUseMap from './AnyMatrixUseMap'; |
import { isInteger } from './Validator'; | ||
import { encode as b64Encode, decode as b46Decode, utf8Decode } from './Base64'; | ||
import * as Base64 from '@cnwhy/base64'; | ||
@@ -147,4 +147,4 @@ const dataMark = [ | ||
} | ||
static input<T extends Matrix>(this: { new (a, b, c?): T },str: string) { | ||
let barray: Uint8Array = b46Decode(str); | ||
static input<T extends Matrix>(this: { new (a, b, c?): T },base64: string) { | ||
let barray: Uint8Array = Base64.decode(base64); | ||
let baseView = new DataView(barray.buffer); | ||
@@ -161,3 +161,3 @@ let width = baseView.getUint32(0); | ||
}else{ | ||
matrix._data = JSON.parse(utf8Decode(barray.buffer.slice(9))); | ||
matrix._data = JSON.parse(Base64.utf8Decode(barray.buffer.slice(9))); | ||
} | ||
@@ -167,2 +167,3 @@ return matrix; | ||
static output(matrix: Matrix) { | ||
if(!(matrix instanceof Matrix)) throw new TypeError('The parameter must be a Matrix type') | ||
let { width, height, total } = matrix; | ||
@@ -177,8 +178,4 @@ let type = dataMark.indexOf(Object.prototype.toString.call(matrix._data)); | ||
baseView.setUint8(8, type); | ||
return b64Encode(baseBuffer) + b64Encode(data); | ||
// Object.create(this, { | ||
// _data: Object.assign(Object.getOwnPropertyDescriptor(this, '_data'), { | ||
// value: new Uint8Array(this._data.buffer.slice(0)) | ||
// }) | ||
// }); | ||
// 由于是baseBuffer是占9byte base64编码时可以直接拼接 | ||
return Base64.encode(baseBuffer) + Base64.encode(data); | ||
} | ||
@@ -185,0 +182,0 @@ output(){ |
@@ -40,3 +40,3 @@ { | ||
/* Module Resolution Options */ | ||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ | ||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ | ||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ | ||
@@ -63,4 +63,3 @@ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ | ||
"node_modules", | ||
"test/**/*.ts", | ||
"Matrixs.ts", | ||
"test/", | ||
"**/*.d.ts", | ||
@@ -67,0 +66,0 @@ "**/*.spec.ts" |
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
95904
1
13
34
2478
+ Added@cnwhy/base64@^0.1.1
+ Added@cnwhy/base64@0.1.3(transitive)