@ -1,21 +0,0 @@ |
|||||||
The MIT License (MIT) |
|
||||||
|
|
||||||
Copyright (c) 2014-2017, Jon Schlinkert. |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||||
of this software and associated documentation files (the "Software"), to deal |
|
||||||
in the Software without restriction, including without limitation the rights |
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||||
copies of the Software, and to permit persons to whom the Software is |
|
||||||
furnished to do so, subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in |
|
||||||
all copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
||||||
THE SOFTWARE. |
|
@ -1,86 +0,0 @@ |
|||||||
# arr-flatten [![NPM version](https://img.shields.io/npm/v/arr-flatten.svg?style=flat)](https://www.npmjs.com/package/arr-flatten) [![NPM monthly downloads](https://img.shields.io/npm/dm/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![NPM total downloads](https://img.shields.io/npm/dt/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/arr-flatten.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/arr-flatten) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/arr-flatten.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/arr-flatten) |
|
||||||
|
|
||||||
> Recursively flatten an array or arrays. |
|
||||||
|
|
||||||
## Install |
|
||||||
|
|
||||||
Install with [npm](https://www.npmjs.com/): |
|
||||||
|
|
||||||
```sh |
|
||||||
$ npm install --save arr-flatten |
|
||||||
``` |
|
||||||
|
|
||||||
## Install |
|
||||||
|
|
||||||
Install with [bower](https://bower.io/) |
|
||||||
|
|
||||||
```sh |
|
||||||
$ bower install arr-flatten --save |
|
||||||
``` |
|
||||||
|
|
||||||
## Usage |
|
||||||
|
|
||||||
```js |
|
||||||
var flatten = require('arr-flatten'); |
|
||||||
|
|
||||||
flatten(['a', ['b', ['c']], 'd', ['e']]); |
|
||||||
//=> ['a', 'b', 'c', 'd', 'e'] |
|
||||||
``` |
|
||||||
|
|
||||||
## Why another flatten utility? |
|
||||||
|
|
||||||
I wanted the fastest implementation I could find, with implementation choices that should work for 95% of use cases, but no cruft to cover the other 5%. |
|
||||||
|
|
||||||
## About |
|
||||||
|
|
||||||
### Related projects |
|
||||||
|
|
||||||
* [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter "Faster alternative to javascript's native filter method.") |
|
||||||
* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.") |
|
||||||
* [array-each](https://www.npmjs.com/package/array-each): Loop over each item in an array and call the given function on every element. | [homepage](https://github.com/jonschlinkert/array-each "Loop over each item in an array and call the given function on every element.") |
|
||||||
* [array-unique](https://www.npmjs.com/package/array-unique): Remove duplicate values from an array. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique "Remove duplicate values from an array. Fastest ES5 implementation.") |
|
||||||
|
|
||||||
### Contributing |
|
||||||
|
|
||||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). |
|
||||||
|
|
||||||
### Contributors |
|
||||||
|
|
||||||
| **Commits** | **Contributor** | |
|
||||||
| --- | --- | |
|
||||||
| 20 | [jonschlinkert](https://github.com/jonschlinkert) | |
|
||||||
| 1 | [lukeed](https://github.com/lukeed) | |
|
||||||
|
|
||||||
### Building docs |
|
||||||
|
|
||||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ |
|
||||||
|
|
||||||
To generate the readme, run the following command: |
|
||||||
|
|
||||||
```sh |
|
||||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb |
|
||||||
``` |
|
||||||
|
|
||||||
### Running tests |
|
||||||
|
|
||||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: |
|
||||||
|
|
||||||
```sh |
|
||||||
$ npm install && npm test |
|
||||||
``` |
|
||||||
|
|
||||||
### Author |
|
||||||
|
|
||||||
**Jon Schlinkert** |
|
||||||
|
|
||||||
* [github/jonschlinkert](https://github.com/jonschlinkert) |
|
||||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) |
|
||||||
|
|
||||||
### License |
|
||||||
|
|
||||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). |
|
||||||
Released under the [MIT License](LICENSE). |
|
||||||
|
|
||||||
*** |
|
||||||
|
|
||||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 05, 2017._ |
|
@ -1,22 +0,0 @@ |
|||||||
/*! |
|
||||||
* arr-flatten <https://github.com/jonschlinkert/arr-flatten>
|
|
||||||
* |
|
||||||
* Copyright (c) 2014-2017, Jon Schlinkert. |
|
||||||
* Released under the MIT License. |
|
||||||
*/ |
|
||||||
|
|
||||||
'use strict'; |
|
||||||
|
|
||||||
module.exports = function (arr) { |
|
||||||
return flat(arr, []); |
|
||||||
}; |
|
||||||
|
|
||||||
function flat(arr, res) { |
|
||||||
var i = 0, cur; |
|
||||||
var len = arr.length; |
|
||||||
for (; i < len; i++) { |
|
||||||
cur = arr[i]; |
|
||||||
Array.isArray(cur) ? flat(cur, res) : res.push(cur); |
|
||||||
} |
|
||||||
return res; |
|
||||||
} |
|
@ -1,115 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "arr-flatten@^1.1.0", |
|
||||||
"_id": "arr-flatten@1.1.0", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", |
|
||||||
"_location": "/arr-flatten", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "arr-flatten@^1.1.0", |
|
||||||
"name": "arr-flatten", |
|
||||||
"escapedName": "arr-flatten", |
|
||||||
"rawSpec": "^1.1.0", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^1.1.0" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/image-pixels", |
|
||||||
"/pxls", |
|
||||||
"/to-uint8" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", |
|
||||||
"_shasum": "36048bbff4e7b47e136644316c99669ea5ae91f1", |
|
||||||
"_spec": "arr-flatten@^1.1.0", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/image-pixels", |
|
||||||
"author": { |
|
||||||
"name": "Jon Schlinkert", |
|
||||||
"url": "https://github.com/jonschlinkert" |
|
||||||
}, |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/jonschlinkert/arr-flatten/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"contributors": [ |
|
||||||
{ |
|
||||||
"name": "Jon Schlinkert", |
|
||||||
"url": "http://twitter.com/jonschlinkert" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Luke Edwards", |
|
||||||
"url": "https://lukeed.com" |
|
||||||
} |
|
||||||
], |
|
||||||
"deprecated": false, |
|
||||||
"description": "Recursively flatten an array or arrays.", |
|
||||||
"devDependencies": { |
|
||||||
"ansi-bold": "^0.1.1", |
|
||||||
"array-flatten": "^2.1.1", |
|
||||||
"array-slice": "^1.0.0", |
|
||||||
"benchmarked": "^1.0.0", |
|
||||||
"compute-flatten": "^1.0.0", |
|
||||||
"flatit": "^1.1.1", |
|
||||||
"flatten": "^1.0.2", |
|
||||||
"flatten-array": "^1.0.0", |
|
||||||
"glob": "^7.1.1", |
|
||||||
"gulp-format-md": "^0.1.12", |
|
||||||
"just-flatten-it": "^1.1.23", |
|
||||||
"lodash.flattendeep": "^4.4.0", |
|
||||||
"m_flattened": "^1.0.1", |
|
||||||
"mocha": "^3.2.0", |
|
||||||
"utils-flatten": "^1.0.0", |
|
||||||
"write": "^0.3.3" |
|
||||||
}, |
|
||||||
"engines": { |
|
||||||
"node": ">=0.10.0" |
|
||||||
}, |
|
||||||
"files": [ |
|
||||||
"index.js" |
|
||||||
], |
|
||||||
"homepage": "https://github.com/jonschlinkert/arr-flatten", |
|
||||||
"keywords": [ |
|
||||||
"arr", |
|
||||||
"array", |
|
||||||
"elements", |
|
||||||
"flat", |
|
||||||
"flatten", |
|
||||||
"nested", |
|
||||||
"recurse", |
|
||||||
"recursive", |
|
||||||
"recursively" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "index.js", |
|
||||||
"name": "arr-flatten", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git+https://github.com/jonschlinkert/arr-flatten.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"test": "mocha" |
|
||||||
}, |
|
||||||
"verb": { |
|
||||||
"toc": false, |
|
||||||
"layout": "default", |
|
||||||
"tasks": [ |
|
||||||
"readme" |
|
||||||
], |
|
||||||
"plugins": [ |
|
||||||
"gulp-format-md" |
|
||||||
], |
|
||||||
"related": { |
|
||||||
"list": [ |
|
||||||
"arr-filter", |
|
||||||
"arr-union", |
|
||||||
"array-each", |
|
||||||
"array-unique" |
|
||||||
] |
|
||||||
}, |
|
||||||
"lint": { |
|
||||||
"reflinks": true |
|
||||||
} |
|
||||||
}, |
|
||||||
"version": "1.1.0" |
|
||||||
} |
|
@ -1,44 +0,0 @@ |
|||||||
{ |
|
||||||
"env": { |
|
||||||
"browser": true, |
|
||||||
"node": true, |
|
||||||
"commonjs": true, |
|
||||||
"es6": true |
|
||||||
}, |
|
||||||
"extends": "eslint:recommended", |
|
||||||
"rules": { |
|
||||||
"strict": 2, |
|
||||||
"indent": 0, |
|
||||||
"linebreak-style": 0, |
|
||||||
"quotes": 0, |
|
||||||
"semi": 0, |
|
||||||
"no-cond-assign": 1, |
|
||||||
"no-constant-condition": 1, |
|
||||||
"no-duplicate-case": 1, |
|
||||||
"no-empty": 1, |
|
||||||
"no-ex-assign": 1, |
|
||||||
"no-extra-boolean-cast": 1, |
|
||||||
"no-extra-semi": 1, |
|
||||||
"no-fallthrough": 1, |
|
||||||
"no-func-assign": 1, |
|
||||||
"no-global-assign": 1, |
|
||||||
"no-implicit-globals": 2, |
|
||||||
"no-inner-declarations": ["error", "functions"], |
|
||||||
"no-irregular-whitespace": 2, |
|
||||||
"no-loop-func": 1, |
|
||||||
"no-magic-numbers": ["warn", { "ignore": [1, 0, -1], "ignoreArrayIndexes": true}], |
|
||||||
"no-multi-str": 1, |
|
||||||
"no-mixed-spaces-and-tabs": 1, |
|
||||||
"no-proto": 1, |
|
||||||
"no-sequences": 1, |
|
||||||
"no-throw-literal": 1, |
|
||||||
"no-unmodified-loop-condition": 1, |
|
||||||
"no-useless-call": 1, |
|
||||||
"no-void": 1, |
|
||||||
"no-with": 2, |
|
||||||
"wrap-iife": 1, |
|
||||||
"no-redeclare": 1, |
|
||||||
"no-unused-vars": ["error", { "vars": "all", "args": "none" }], |
|
||||||
"no-sparse-arrays": 1 |
|
||||||
} |
|
||||||
} |
|
@ -1,5 +0,0 @@ |
|||||||
language: node_js |
|
||||||
node_js: |
|
||||||
- '6' |
|
||||||
- '5' |
|
||||||
- '4' |
|
@ -1,45 +0,0 @@ |
|||||||
/** |
|
||||||
* @module arraybuffer-to-string/browser |
|
||||||
*/ |
|
||||||
|
|
||||||
'use strict' |
|
||||||
|
|
||||||
module.exports = function ArrayBufferToString (buffer, encoding) { |
|
||||||
if (encoding == null) encoding = 'utf8' |
|
||||||
|
|
||||||
var uint8 = new Uint8Array(buffer) |
|
||||||
|
|
||||||
if (encoding === 'hex') { |
|
||||||
var out = '' |
|
||||||
for (var i = 0, l = uint8.byteLength; i < l; ++i) { |
|
||||||
out += toHex(uint8[i]) |
|
||||||
} |
|
||||||
return out |
|
||||||
} |
|
||||||
|
|
||||||
if (encoding === 'base64') { |
|
||||||
str = String.fromCharCode.apply(null, uint8) |
|
||||||
return btoa(str) |
|
||||||
} |
|
||||||
|
|
||||||
if (encoding === 'binary' || |
|
||||||
encoding === 'latin1' || |
|
||||||
!global.TextDecoder) { |
|
||||||
str = String.fromCharCode.apply(null, uint8) |
|
||||||
return str |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
//TextDecoder way
|
|
||||||
if (encoding === 'utf16le') encoding = 'utf-16le' |
|
||||||
|
|
||||||
var decoder = new TextDecoder(encoding) |
|
||||||
var str = decoder.decode(uint8) |
|
||||||
return str |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
function toHex (n) { |
|
||||||
if (n < 16) return '0' + n.toString(16) |
|
||||||
return n.toString(16) |
|
||||||
} |
|
@ -1,11 +0,0 @@ |
|||||||
/** |
|
||||||
* @module arraybuffer-to-string |
|
||||||
*/ |
|
||||||
|
|
||||||
'use strict' |
|
||||||
|
|
||||||
module.exports = function ArrayBufferToString (buffer, encoding) { |
|
||||||
if (encoding == null) encoding = 'utf8' |
|
||||||
|
|
||||||
return Buffer.from(buffer).toString(encoding) |
|
||||||
} |
|
@ -1,65 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "arraybuffer-to-string@^1.0.2", |
|
||||||
"_id": "arraybuffer-to-string@1.0.2", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha512-WbIYlLVmvIAyUBdQRRuyGOJRriOQy9OAsWcyURmsRQp9+g647hdMSS2VFKXbJLVw0daUu06hqwLXm9etVrXI9A==", |
|
||||||
"_location": "/arraybuffer-to-string", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "arraybuffer-to-string@^1.0.2", |
|
||||||
"name": "arraybuffer-to-string", |
|
||||||
"escapedName": "arraybuffer-to-string", |
|
||||||
"rawSpec": "^1.0.2", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^1.0.2" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/image-pixels" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/arraybuffer-to-string/-/arraybuffer-to-string-1.0.2.tgz", |
|
||||||
"_shasum": "c373aa7bb0e6844d9a2bc9654c8889a9570a26e2", |
|
||||||
"_spec": "arraybuffer-to-string@^1.0.2", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/image-pixels", |
|
||||||
"author": { |
|
||||||
"name": "Dima Yv", |
|
||||||
"email": "dfcreative@gmail.com" |
|
||||||
}, |
|
||||||
"browser": "./browser.js", |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/dfcreative/arraybuffer-to-string/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"deprecated": false, |
|
||||||
"description": "Convert ArrayBuffer to string", |
|
||||||
"devDependencies": { |
|
||||||
"buffer-to-arraybuffer": "0.0.4", |
|
||||||
"is-browser": "^2.0.1", |
|
||||||
"string-to-arraybuffer": "^1.0.0", |
|
||||||
"tape": "^4.7.0" |
|
||||||
}, |
|
||||||
"homepage": "https://github.com/dfcreative/arraybuffer-to-string#readme", |
|
||||||
"keywords": [ |
|
||||||
"arraybuffer", |
|
||||||
"array-buffer", |
|
||||||
"array", |
|
||||||
"buffer", |
|
||||||
"string", |
|
||||||
"base64", |
|
||||||
"atob", |
|
||||||
"btoa", |
|
||||||
"datauri" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "index.js", |
|
||||||
"name": "arraybuffer-to-string", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git+https://github.com/dfcreative/arraybuffer-to-string.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"test": "node test.js" |
|
||||||
}, |
|
||||||
"version": "1.0.2" |
|
||||||
} |
|
@ -1,27 +0,0 @@ |
|||||||
# arraybuffer-to-string [![unstable](https://img.shields.io/badge/stability-unstable-orange.svg)](http://github.com/badges/stability-badges) [![Build Status](https://img.shields.io/travis/dfcreative/arraybuffer-to-string.svg)](https://travis-ci.org/dfcreative/arraybuffer-to-string) |
|
||||||
|
|
||||||
Convert _ArrayBuffer_ to string with optional encoding. |
|
||||||
|
|
||||||
[![npm install arraybuffer-to-string](https://nodei.co/npm/arraybuffer-to-string.png?mini=true)](https://npmjs.org/package/arraybuffer-to-string/) |
|
||||||
|
|
||||||
```js |
|
||||||
var ab2str = require('arraybuffer-to-string') |
|
||||||
|
|
||||||
var uint8 = new Uint8Array([ 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33 ]) |
|
||||||
|
|
||||||
ab2str(uint8) // 'Hello World!' |
|
||||||
ab2str(uint8, 'base64') // 'SGVsbG8gV29ybGQh' |
|
||||||
ab2str(uint8, 'hex') // '48656c6c6f20576f726c6421' |
|
||||||
ab2str(uint8, 'iso-8859-2') // 'Hello World!' |
|
||||||
``` |
|
||||||
|
|
||||||
### var str = arrayBufferToString(buffer, encoding='utf8') |
|
||||||
|
|
||||||
Convert ArrayBuffer/ArrayBufferView/Array `buffer` to string with defined encoding. Available encoding: `utf8`, `binary`, `base64`, `hex`, `ascii`, `latin1`, `ucs2`, `utf16` and [many others](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/encoding). |
|
||||||
|
|
||||||
Note: in browser it relies on [TextDecoder API](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/decode), so if you are dealing with charsets other than `utf8`, `ascii`, `binary` or `base64` in old browsers, please include [encoding polyfill](https://github.com/inexorabletash/text-encoding). |
|
||||||
|
|
||||||
### Related |
|
||||||
|
|
||||||
* [string-to-arraybuffer](https://github.com/dfcreative/string-to-arraybuffer) − convert string to arraybuffer. |
|
||||||
* [create-data-uri](https://www.npmjs.com/package/create-data-uri) − convert binary data to datauri string. |
|
@ -1,6 +0,0 @@ |
|||||||
node_modules |
|
||||||
*.log |
|
||||||
.DS_Store |
|
||||||
bundle.js |
|
||||||
test |
|
||||||
test.js |
|
@ -1,18 +0,0 @@ |
|||||||
This software is released under the MIT license: |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
||||||
this software and associated documentation files (the "Software"), to deal in |
|
||||||
the Software without restriction, including without limitation the rights to |
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
||||||
the Software, and to permit persons to whom the Software is furnished to do so, |
|
||||||
subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all |
|
||||||
copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
||||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
||||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
||||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
@ -1,37 +0,0 @@ |
|||||||
# atob-lite |
|
||||||
![](http://img.shields.io/badge/stability-stable-orange.svg?style=flat) |
|
||||||
![](http://img.shields.io/npm/v/atob-lite.svg?style=flat) |
|
||||||
![](http://img.shields.io/npm/dm/atob-lite.svg?style=flat) |
|
||||||
![](http://img.shields.io/npm/l/atob-lite.svg?style=flat) |
|
||||||
|
|
||||||
Smallest/simplest possible means of using atob with both Node and browserify. |
|
||||||
|
|
||||||
In the browser, decoding base64 strings is done using: |
|
||||||
|
|
||||||
``` javascript |
|
||||||
var decoded = atob(encoded) |
|
||||||
``` |
|
||||||
|
|
||||||
However in Node, it's done like so: |
|
||||||
|
|
||||||
``` javascript |
|
||||||
var decoded = new Buffer(encoded, 'base64').toString('utf8') |
|
||||||
``` |
|
||||||
|
|
||||||
You can easily check if `Buffer` exists and switch between the approaches |
|
||||||
accordingly, but using `Buffer` anywhere in your browser source will pull |
|
||||||
in browserify's `Buffer` shim which is pretty hefty. This package uses |
|
||||||
the `main` and `browser` fields in its `package.json` to perform this |
|
||||||
check at build time and avoid pulling `Buffer` in unnecessarily. |
|
||||||
|
|
||||||
## Usage |
|
||||||
|
|
||||||
[![NPM](https://nodei.co/npm/atob-lite.png)](https://nodei.co/npm/atob-lite/) |
|
||||||
|
|
||||||
### `decoded = atob(encoded)` |
|
||||||
|
|
||||||
Returns the decoded value of a base64-encoded string. |
|
||||||
|
|
||||||
## License |
|
||||||
|
|
||||||
MIT. See [LICENSE.md](http://github.com/hughsk/atob-lite/blob/master/LICENSE.md) for details. |
|
@ -1,3 +0,0 @@ |
|||||||
module.exports = function _atob(str) { |
|
||||||
return atob(str) |
|
||||||
} |
|
@ -1,3 +0,0 @@ |
|||||||
module.exports = function atob(str) { |
|
||||||
return Buffer.from(str, 'base64').toString('binary') |
|
||||||
} |
|
@ -1,67 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "atob-lite@^2.0.0", |
|
||||||
"_id": "atob-lite@2.0.0", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=", |
|
||||||
"_location": "/atob-lite", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "atob-lite@^2.0.0", |
|
||||||
"name": "atob-lite", |
|
||||||
"escapedName": "atob-lite", |
|
||||||
"rawSpec": "^2.0.0", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^2.0.0" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/string-to-arraybuffer" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz", |
|
||||||
"_shasum": "0fef5ad46f1bd7a8502c65727f0367d5ee43d696", |
|
||||||
"_spec": "atob-lite@^2.0.0", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/string-to-arraybuffer", |
|
||||||
"author": { |
|
||||||
"name": "Hugh Kennedy", |
|
||||||
"email": "hughskennedy@gmail.com", |
|
||||||
"url": "http://hughsk.io/" |
|
||||||
}, |
|
||||||
"browser": "atob-browser.js", |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/hughsk/atob-lite/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"dependencies": {}, |
|
||||||
"deprecated": false, |
|
||||||
"description": "Smallest/simplest possible means of using atob with both Node and browserify", |
|
||||||
"devDependencies": { |
|
||||||
"browserify": "^10.2.4", |
|
||||||
"smokestack": "^3.3.0", |
|
||||||
"tap-closer": "^1.0.0", |
|
||||||
"tap-spec": "^4.0.0", |
|
||||||
"tape": "^4.0.0" |
|
||||||
}, |
|
||||||
"homepage": "https://github.com/hughsk/atob-lite", |
|
||||||
"keywords": [ |
|
||||||
"atob", |
|
||||||
"base64", |
|
||||||
"isomorphic", |
|
||||||
"browser", |
|
||||||
"node", |
|
||||||
"shared" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "atob-node.js", |
|
||||||
"name": "atob-lite", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git://github.com/hughsk/atob-lite.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"test": "npm run test-node && npm run test-browser", |
|
||||||
"test-browser": "browserify test | smokestack | tap-spec", |
|
||||||
"test-node": "node test | tap-spec" |
|
||||||
}, |
|
||||||
"version": "2.0.0" |
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
node_modules |
|
||||||
.idea |
|
@ -1,21 +0,0 @@ |
|||||||
The MIT License (MIT) |
|
||||||
|
|
||||||
Copyright (c) 2014 @丝刀口 |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||||
of this software and associated documentation files (the "Software"), to deal |
|
||||||
in the Software without restriction, including without limitation the rights |
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||||
copies of the Software, and to permit persons to whom the Software is |
|
||||||
furnished to do so, subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all |
|
||||||
copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||||
SOFTWARE. |
|
@ -1,44 +0,0 @@ |
|||||||
bmp-js |
|
||||||
====== |
|
||||||
|
|
||||||
A pure javascript Bmp encoder and decoder for node.js |
|
||||||
|
|
||||||
Supports all bits decoding(1,4,8,16,24,32) and encoding with 24bit. |
|
||||||
|
|
||||||
##Install |
|
||||||
|
|
||||||
$ npm install bmp-js |
|
||||||
|
|
||||||
|
|
||||||
How to use? |
|
||||||
--- |
|
||||||
###Decode BMP |
|
||||||
```js |
|
||||||
var bmp = require("bmp-js"); |
|
||||||
var bmpBuffer = fs.readFileSync('bit24.bmp'); |
|
||||||
var bmpData = bmp.decode(bmpBuffer); |
|
||||||
|
|
||||||
``` |
|
||||||
|
|
||||||
`bmpData` has all properties includes: |
|
||||||
|
|
||||||
1. fileSize,reserved,offset |
|
||||||
|
|
||||||
2. headerSize,width,height,planes,bitPP,compress,rawSize,hr,vr,colors,importantColors |
|
||||||
|
|
||||||
3. palette |
|
||||||
|
|
||||||
4. data-------byte array order by ABGR ABGR ABGR,4 bytes per pixel |
|
||||||
|
|
||||||
|
|
||||||
###Encode RGB |
|
||||||
```js |
|
||||||
var bmp = require("bmp-js"); |
|
||||||
//bmpData={data:Buffer,width:Number,height:Height} |
|
||||||
var rawData = bmp.encode(bmpData);//default no compression,write rawData to .bmp file |
|
||||||
|
|
||||||
``` |
|
||||||
|
|
||||||
License |
|
||||||
--- |
|
||||||
U can use on free with [MIT License](https://github.com/shaozilee/bmp-js/blob/master/LICENSE) |
|
@ -1,9 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<module type="WEB_MODULE" version="4"> |
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true"> |
|
||||||
<exclude-output /> |
|
||||||
<content url="file://$MODULE_DIR$" /> |
|
||||||
<orderEntry type="inheritedJdk" /> |
|
||||||
<orderEntry type="sourceFolder" forTests="false" /> |
|
||||||
</component> |
|
||||||
</module> |
|
@ -1,15 +0,0 @@ |
|||||||
/** |
|
||||||
* @author shaozilee |
|
||||||
* |
|
||||||
* support 1bit 4bit 8bit 24bit decode |
|
||||||
* encode with 24bit |
|
||||||
*
|
|
||||||
*/ |
|
||||||
|
|
||||||
var encode = require('./lib/encoder'), |
|
||||||
decode = require('./lib/decoder'); |
|
||||||
|
|
||||||
module.exports = { |
|
||||||
encode: encode, |
|
||||||
decode: decode |
|
||||||
}; |
|
@ -1,485 +0,0 @@ |
|||||||
/** |
|
||||||
* @author shaozilee |
|
||||||
* |
|
||||||
* Bmp format decoder,support 1bit 4bit 8bit 24bit bmp |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
function BmpDecoder(buffer,is_with_alpha) { |
|
||||||
this.pos = 0; |
|
||||||
this.buffer = buffer; |
|
||||||
this.is_with_alpha = !!is_with_alpha; |
|
||||||
this.bottom_up = true; |
|
||||||
this.flag = this.buffer.toString("utf-8", 0, this.pos += 2); |
|
||||||
if (this.flag != "BM") throw new Error("Invalid BMP File"); |
|
||||||
this.parseHeader(); |
|
||||||
this.parseRGBA(); |
|
||||||
} |
|
||||||
|
|
||||||
BmpDecoder.prototype.parseHeader = function() { |
|
||||||
this.fileSize = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.reserved = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.offset = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.headerSize = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.width = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.height = this.buffer.readInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.planes = this.buffer.readUInt16LE(this.pos); |
|
||||||
this.pos += 2; |
|
||||||
this.bitPP = this.buffer.readUInt16LE(this.pos); |
|
||||||
this.pos += 2; |
|
||||||
this.compress = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.rawSize = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.hr = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.vr = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.colors = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
this.importantColors = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos += 4; |
|
||||||
|
|
||||||
if(this.bitPP === 16 && this.is_with_alpha){ |
|
||||||
this.bitPP = 15 |
|
||||||
} |
|
||||||
if (this.bitPP < 15) { |
|
||||||
var len = this.colors === 0 ? 1 << this.bitPP : this.colors; |
|
||||||
this.palette = new Array(len); |
|
||||||
for (var i = 0; i < len; i++) { |
|
||||||
var blue = this.buffer.readUInt8(this.pos++); |
|
||||||
var green = this.buffer.readUInt8(this.pos++); |
|
||||||
var red = this.buffer.readUInt8(this.pos++); |
|
||||||
var quad = this.buffer.readUInt8(this.pos++); |
|
||||||
this.palette[i] = { |
|
||||||
red: red, |
|
||||||
green: green, |
|
||||||
blue: blue, |
|
||||||
quad: quad |
|
||||||
}; |
|
||||||
} |
|
||||||
} |
|
||||||
if(this.height < 0) { |
|
||||||
this.height *= -1; |
|
||||||
this.bottom_up = false; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
BmpDecoder.prototype.parseRGBA = function() { |
|
||||||
var bitn = "bit" + this.bitPP; |
|
||||||
var len = this.width * this.height * 4; |
|
||||||
this.data = new Buffer(len); |
|
||||||
this[bitn](); |
|
||||||
}; |
|
||||||
|
|
||||||
BmpDecoder.prototype.bit1 = function() { |
|
||||||
var xlen = Math.ceil(this.width / 8); |
|
||||||
var mode = xlen%4; |
|
||||||
var y = this.height >= 0 ? this.height - 1 : -this.height |
|
||||||
for (var y = this.height - 1; y >= 0; y--) { |
|
||||||
var line = this.bottom_up ? y : this.height - 1 - y |
|
||||||
for (var x = 0; x < xlen; x++) { |
|
||||||
var b = this.buffer.readUInt8(this.pos++); |
|
||||||
var location = line * this.width * 4 + x*8*4; |
|
||||||
for (var i = 0; i < 8; i++) { |
|
||||||
if(x*8+i<this.width){ |
|
||||||
var rgb = this.palette[((b>>(7-i))&0x1)]; |
|
||||||
|
|
||||||
this.data[location+i*4] = 0; |
|
||||||
this.data[location+i*4 + 1] = rgb.blue; |
|
||||||
this.data[location+i*4 + 2] = rgb.green; |
|
||||||
this.data[location+i*4 + 3] = rgb.red; |
|
||||||
|
|
||||||
}else{ |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (mode != 0){ |
|
||||||
this.pos+=(4 - mode); |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
BmpDecoder.prototype.bit4 = function() { |
|
||||||
//RLE-4
|
|
||||||
if(this.compress == 2){ |
|
||||||
this.data.fill(0xff); |
|
||||||
|
|
||||||
var location = 0; |
|
||||||
var lines = this.bottom_up?this.height-1:0; |
|
||||||
var low_nibble = false;//for all count of pixel
|
|
||||||
|
|
||||||
while(location<this.data.length){ |
|
||||||
var a = this.buffer.readUInt8(this.pos++); |
|
||||||
var b = this.buffer.readUInt8(this.pos++); |
|
||||||
//absolute mode
|
|
||||||
if(a == 0){ |
|
||||||
if(b == 0){//line end
|
|
||||||
if(this.bottom_up){ |
|
||||||
lines--; |
|
||||||
}else{ |
|
||||||
lines++; |
|
||||||
} |
|
||||||
location = lines*this.width*4; |
|
||||||
low_nibble = false; |
|
||||||
continue; |
|
||||||
}else if(b == 1){//image end
|
|
||||||
break; |
|
||||||
}else if(b ==2){ |
|
||||||
//offset x,y
|
|
||||||
var x = this.buffer.readUInt8(this.pos++); |
|
||||||
var y = this.buffer.readUInt8(this.pos++); |
|
||||||
if(this.bottom_up){ |
|
||||||
lines-=y; |
|
||||||
}else{ |
|
||||||
lines+=y; |
|
||||||
} |
|
||||||
|
|
||||||
location +=(y*this.width*4+x*4); |
|
||||||
}else{ |
|
||||||
var c = this.buffer.readUInt8(this.pos++); |
|
||||||
for(var i=0;i<b;i++){ |
|
||||||
if (low_nibble) { |
|
||||||
setPixelData.call(this, (c & 0x0f)); |
|
||||||
} else { |
|
||||||
setPixelData.call(this, (c & 0xf0)>>4); |
|
||||||
} |
|
||||||
|
|
||||||
if ((i & 1) && (i+1 < b)){ |
|
||||||
c = this.buffer.readUInt8(this.pos++); |
|
||||||
} |
|
||||||
|
|
||||||
low_nibble = !low_nibble; |
|
||||||
} |
|
||||||
|
|
||||||
if ((((b+1) >> 1) & 1 ) == 1){ |
|
||||||
this.pos++ |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
}else{//encoded mode
|
|
||||||
for (var i = 0; i < a; i++) { |
|
||||||
if (low_nibble) { |
|
||||||
setPixelData.call(this, (b & 0x0f)); |
|
||||||
} else { |
|
||||||
setPixelData.call(this, (b & 0xf0)>>4); |
|
||||||
} |
|
||||||
low_nibble = !low_nibble; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function setPixelData(rgbIndex){ |
|
||||||
var rgb = this.palette[rgbIndex]; |
|
||||||
this.data[location] = 0; |
|
||||||
this.data[location + 1] = rgb.blue; |
|
||||||
this.data[location + 2] = rgb.green; |
|
||||||
this.data[location + 3] = rgb.red; |
|
||||||
location+=4; |
|
||||||
} |
|
||||||
}else{ |
|
||||||
|
|
||||||
var xlen = Math.ceil(this.width/2); |
|
||||||
var mode = xlen%4; |
|
||||||
for (var y = this.height - 1; y >= 0; y--) { |
|
||||||
var line = this.bottom_up ? y : this.height - 1 - y |
|
||||||
for (var x = 0; x < xlen; x++) { |
|
||||||
var b = this.buffer.readUInt8(this.pos++); |
|
||||||
var location = line * this.width * 4 + x*2*4; |
|
||||||
|
|
||||||
var before = b>>4; |
|
||||||
var after = b&0x0F; |
|
||||||
|
|
||||||
var rgb = this.palette[before]; |
|
||||||
this.data[location] = 0; |
|
||||||
this.data[location + 1] = rgb.blue; |
|
||||||
this.data[location + 2] = rgb.green; |
|
||||||
this.data[location + 3] = rgb.red; |
|
||||||
|
|
||||||
|
|
||||||
if(x*2+1>=this.width)break; |
|
||||||
|
|
||||||
rgb = this.palette[after]; |
|
||||||
|
|
||||||
this.data[location+4] = 0; |
|
||||||
this.data[location+4 + 1] = rgb.blue; |
|
||||||
this.data[location+4 + 2] = rgb.green; |
|
||||||
this.data[location+4 + 3] = rgb.red; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
if (mode != 0){ |
|
||||||
this.pos+=(4 - mode); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
}; |
|
||||||
|
|
||||||
BmpDecoder.prototype.bit8 = function() { |
|
||||||
//RLE-8
|
|
||||||
if(this.compress == 1){ |
|
||||||
this.data.fill(0xff); |
|
||||||
|
|
||||||
var location = 0; |
|
||||||
var lines = this.bottom_up?this.height-1:0; |
|
||||||
|
|
||||||
while(location<this.data.length){ |
|
||||||
var a = this.buffer.readUInt8(this.pos++); |
|
||||||
var b = this.buffer.readUInt8(this.pos++); |
|
||||||
//absolute mode
|
|
||||||
if(a == 0){ |
|
||||||
if(b == 0){//line end
|
|
||||||
if(this.bottom_up){ |
|
||||||
lines--; |
|
||||||
}else{ |
|
||||||
lines++; |
|
||||||
} |
|
||||||
location = lines*this.width*4; |
|
||||||
continue; |
|
||||||
}else if(b == 1){//image end
|
|
||||||
break; |
|
||||||
}else if(b ==2){ |
|
||||||
//offset x,y
|
|
||||||
var x = this.buffer.readUInt8(this.pos++); |
|
||||||
var y = this.buffer.readUInt8(this.pos++); |
|
||||||
if(this.bottom_up){ |
|
||||||
lines-=y; |
|
||||||
}else{ |
|
||||||
lines+=y; |
|
||||||
} |
|
||||||
|
|
||||||
location +=(y*this.width*4+x*4); |
|
||||||
}else{ |
|
||||||
for(var i=0;i<b;i++){ |
|
||||||
var c = this.buffer.readUInt8(this.pos++); |
|
||||||
setPixelData.call(this, c); |
|
||||||
} |
|
||||||
if(b&1 == 1){ |
|
||||||
this.pos++; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
}else{//encoded mode
|
|
||||||
for (var i = 0; i < a; i++) { |
|
||||||
setPixelData.call(this, b); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function setPixelData(rgbIndex){ |
|
||||||
var rgb = this.palette[rgbIndex]; |
|
||||||
this.data[location] = 0; |
|
||||||
this.data[location + 1] = rgb.blue; |
|
||||||
this.data[location + 2] = rgb.green; |
|
||||||
this.data[location + 3] = rgb.red; |
|
||||||
location+=4; |
|
||||||
} |
|
||||||
}else { |
|
||||||
var mode = this.width % 4; |
|
||||||
for (var y = this.height - 1; y >= 0; y--) { |
|
||||||
var line = this.bottom_up ? y : this.height - 1 - y |
|
||||||
for (var x = 0; x < this.width; x++) { |
|
||||||
var b = this.buffer.readUInt8(this.pos++); |
|
||||||
var location = line * this.width * 4 + x * 4; |
|
||||||
if (b < this.palette.length) { |
|
||||||
var rgb = this.palette[b]; |
|
||||||
|
|
||||||
this.data[location] = 0; |
|
||||||
this.data[location + 1] = rgb.blue; |
|
||||||
this.data[location + 2] = rgb.green; |
|
||||||
this.data[location + 3] = rgb.red; |
|
||||||
|
|
||||||
} else { |
|
||||||
this.data[location] = 0; |
|
||||||
this.data[location + 1] = 0xFF; |
|
||||||
this.data[location + 2] = 0xFF; |
|
||||||
this.data[location + 3] = 0xFF; |
|
||||||
} |
|
||||||
} |
|
||||||
if (mode != 0) { |
|
||||||
this.pos += (4 - mode); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
BmpDecoder.prototype.bit15 = function() { |
|
||||||
var dif_w =this.width % 3; |
|
||||||
var _11111 = parseInt("11111", 2),_1_5 = _11111; |
|
||||||
for (var y = this.height - 1; y >= 0; y--) { |
|
||||||
var line = this.bottom_up ? y : this.height - 1 - y |
|
||||||
for (var x = 0; x < this.width; x++) { |
|
||||||
|
|
||||||
var B = this.buffer.readUInt16LE(this.pos); |
|
||||||
this.pos+=2; |
|
||||||
var blue = (B & _1_5) / _1_5 * 255 | 0; |
|
||||||
var green = (B >> 5 & _1_5 ) / _1_5 * 255 | 0; |
|
||||||
var red = (B >> 10 & _1_5) / _1_5 * 255 | 0; |
|
||||||
var alpha = (B>>15)?0xFF:0x00; |
|
||||||
|
|
||||||
var location = line * this.width * 4 + x * 4; |
|
||||||
|
|
||||||
this.data[location] = alpha; |
|
||||||
this.data[location + 1] = blue; |
|
||||||
this.data[location + 2] = green; |
|
||||||
this.data[location + 3] = red; |
|
||||||
} |
|
||||||
//skip extra bytes
|
|
||||||
this.pos += dif_w; |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
BmpDecoder.prototype.bit16 = function() { |
|
||||||
var dif_w =(this.width % 2)*2; |
|
||||||
//default xrgb555
|
|
||||||
this.maskRed = 0x7C00; |
|
||||||
this.maskGreen = 0x3E0; |
|
||||||
this.maskBlue =0x1F; |
|
||||||
this.mask0 = 0; |
|
||||||
|
|
||||||
if(this.compress == 3){ |
|
||||||
this.maskRed = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos+=4; |
|
||||||
this.maskGreen = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos+=4; |
|
||||||
this.maskBlue = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos+=4; |
|
||||||
this.mask0 = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos+=4; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
var ns=[0,0,0]; |
|
||||||
for (var i=0;i<16;i++){ |
|
||||||
if ((this.maskRed>>i)&0x01) ns[0]++; |
|
||||||
if ((this.maskGreen>>i)&0x01) ns[1]++; |
|
||||||
if ((this.maskBlue>>i)&0x01) ns[2]++; |
|
||||||
} |
|
||||||
ns[1]+=ns[0]; ns[2]+=ns[1]; ns[0]=8-ns[0]; ns[1]-=8; ns[2]-=8; |
|
||||||
|
|
||||||
for (var y = this.height - 1; y >= 0; y--) { |
|
||||||
var line = this.bottom_up ? y : this.height - 1 - y; |
|
||||||
for (var x = 0; x < this.width; x++) { |
|
||||||
|
|
||||||
var B = this.buffer.readUInt16LE(this.pos); |
|
||||||
this.pos+=2; |
|
||||||
|
|
||||||
var blue = (B&this.maskBlue)<<ns[0]; |
|
||||||
var green = (B&this.maskGreen)>>ns[1]; |
|
||||||
var red = (B&this.maskRed)>>ns[2]; |
|
||||||
|
|
||||||
var location = line * this.width * 4 + x * 4; |
|
||||||
|
|
||||||
this.data[location] = 0; |
|
||||||
this.data[location + 1] = blue; |
|
||||||
this.data[location + 2] = green; |
|
||||||
this.data[location + 3] = red; |
|
||||||
} |
|
||||||
//skip extra bytes
|
|
||||||
this.pos += dif_w; |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
BmpDecoder.prototype.bit24 = function() { |
|
||||||
for (var y = this.height - 1; y >= 0; y--) { |
|
||||||
var line = this.bottom_up ? y : this.height - 1 - y |
|
||||||
for (var x = 0; x < this.width; x++) { |
|
||||||
//Little Endian rgb
|
|
||||||
var blue = this.buffer.readUInt8(this.pos++); |
|
||||||
var green = this.buffer.readUInt8(this.pos++); |
|
||||||
var red = this.buffer.readUInt8(this.pos++); |
|
||||||
var location = line * this.width * 4 + x * 4; |
|
||||||
this.data[location] = 0; |
|
||||||
this.data[location + 1] = blue; |
|
||||||
this.data[location + 2] = green; |
|
||||||
this.data[location + 3] = red; |
|
||||||
} |
|
||||||
//skip extra bytes
|
|
||||||
this.pos += (this.width % 4); |
|
||||||
} |
|
||||||
|
|
||||||
}; |
|
||||||
|
|
||||||
/** |
|
||||||
* add 32bit decode func |
|
||||||
* @author soubok |
|
||||||
*/ |
|
||||||
BmpDecoder.prototype.bit32 = function() { |
|
||||||
//BI_BITFIELDS
|
|
||||||
if(this.compress == 3){ |
|
||||||
this.maskRed = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos+=4; |
|
||||||
this.maskGreen = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos+=4; |
|
||||||
this.maskBlue = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos+=4; |
|
||||||
this.mask0 = this.buffer.readUInt32LE(this.pos); |
|
||||||
this.pos+=4; |
|
||||||
for (var y = this.height - 1; y >= 0; y--) { |
|
||||||
var line = this.bottom_up ? y : this.height - 1 - y; |
|
||||||
for (var x = 0; x < this.width; x++) { |
|
||||||
//Little Endian rgba
|
|
||||||
var alpha = this.buffer.readUInt8(this.pos++); |
|
||||||
var blue = this.buffer.readUInt8(this.pos++); |
|
||||||
var green = this.buffer.readUInt8(this.pos++); |
|
||||||
var red = this.buffer.readUInt8(this.pos++); |
|
||||||
var location = line * this.width * 4 + x * 4; |
|
||||||
this.data[location] = alpha; |
|
||||||
this.data[location + 1] = blue; |
|
||||||
this.data[location + 2] = green; |
|
||||||
this.data[location + 3] = red; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
}else{ |
|
||||||
for (var y = this.height - 1; y >= 0; y--) { |
|
||||||
var line = this.bottom_up ? y : this.height - 1 - y; |
|
||||||
for (var x = 0; x < this.width; x++) { |
|
||||||
//Little Endian argb
|
|
||||||
var blue = this.buffer.readUInt8(this.pos++); |
|
||||||
var green = this.buffer.readUInt8(this.pos++); |
|
||||||
var red = this.buffer.readUInt8(this.pos++); |
|
||||||
var alpha = this.buffer.readUInt8(this.pos++); |
|
||||||
var location = line * this.width * 4 + x * 4; |
|
||||||
this.data[location] = alpha; |
|
||||||
this.data[location + 1] = blue; |
|
||||||
this.data[location + 2] = green; |
|
||||||
this.data[location + 3] = red; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}; |
|
||||||
|
|
||||||
BmpDecoder.prototype.getData = function() { |
|
||||||
return this.data; |
|
||||||
}; |
|
||||||
|
|
||||||
module.exports = function(bmpData) { |
|
||||||
var decoder = new BmpDecoder(bmpData); |
|
||||||
return decoder; |
|
||||||
}; |
|
@ -1,81 +0,0 @@ |
|||||||
/** |
|
||||||
* @author shaozilee |
|
||||||
* |
|
||||||
* BMP format encoder,encode 24bit BMP |
|
||||||
* Not support quality compression |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
function BmpEncoder(imgData){ |
|
||||||
this.buffer = imgData.data; |
|
||||||
this.width = imgData.width; |
|
||||||
this.height = imgData.height; |
|
||||||
this.extraBytes = this.width%4; |
|
||||||
this.rgbSize = this.height*(3*this.width+this.extraBytes); |
|
||||||
this.headerInfoSize = 40; |
|
||||||
|
|
||||||
this.data = []; |
|
||||||
/******************header***********************/ |
|
||||||
this.flag = "BM"; |
|
||||||
this.reserved = 0; |
|
||||||
this.offset = 54; |
|
||||||
this.fileSize = this.rgbSize+this.offset; |
|
||||||
this.planes = 1; |
|
||||||
this.bitPP = 24; |
|
||||||
this.compress = 0; |
|
||||||
this.hr = 0; |
|
||||||
this.vr = 0; |
|
||||||
this.colors = 0; |
|
||||||
this.importantColors = 0; |
|
||||||
} |
|
||||||
|
|
||||||
BmpEncoder.prototype.encode = function() { |
|
||||||
var tempBuffer = new Buffer(this.offset+this.rgbSize); |
|
||||||
this.pos = 0; |
|
||||||
tempBuffer.write(this.flag,this.pos,2);this.pos+=2; |
|
||||||
tempBuffer.writeUInt32LE(this.fileSize,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeUInt32LE(this.reserved,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeUInt32LE(this.offset,this.pos);this.pos+=4; |
|
||||||
|
|
||||||
tempBuffer.writeUInt32LE(this.headerInfoSize,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeUInt32LE(this.width,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeInt32LE(-this.height,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeUInt16LE(this.planes,this.pos);this.pos+=2; |
|
||||||
tempBuffer.writeUInt16LE(this.bitPP,this.pos);this.pos+=2; |
|
||||||
tempBuffer.writeUInt32LE(this.compress,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeUInt32LE(this.rgbSize,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeUInt32LE(this.hr,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeUInt32LE(this.vr,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeUInt32LE(this.colors,this.pos);this.pos+=4; |
|
||||||
tempBuffer.writeUInt32LE(this.importantColors,this.pos);this.pos+=4; |
|
||||||
|
|
||||||
var i=0; |
|
||||||
var rowBytes = 3*this.width+this.extraBytes; |
|
||||||
|
|
||||||
for (var y = 0; y <this.height; y++){ |
|
||||||
for (var x = 0; x < this.width; x++){ |
|
||||||
var p = this.pos+y*rowBytes+x*3; |
|
||||||
i++;//a
|
|
||||||
tempBuffer[p]= this.buffer[i++];//b
|
|
||||||
tempBuffer[p+1] = this.buffer[i++];//g
|
|
||||||
tempBuffer[p+2] = this.buffer[i++];//r
|
|
||||||
} |
|
||||||
if(this.extraBytes>0){ |
|
||||||
var fillOffset = this.pos+y*rowBytes+this.width*3; |
|
||||||
tempBuffer.fill(0,fillOffset,fillOffset+this.extraBytes); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return tempBuffer; |
|
||||||
}; |
|
||||||
|
|
||||||
module.exports = function(imgData, quality) { |
|
||||||
if (typeof quality === 'undefined') quality = 100; |
|
||||||
var encoder = new BmpEncoder(imgData); |
|
||||||
var data = encoder.encode(); |
|
||||||
return { |
|
||||||
data: data, |
|
||||||
width: imgData.width, |
|
||||||
height: imgData.height |
|
||||||
}; |
|
||||||
}; |
|
@ -1,60 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "bmp-js@^0.1.0", |
|
||||||
"_id": "bmp-js@0.1.0", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha1-4Fpj95amwf8l9Hcex62twUjAcjM=", |
|
||||||
"_location": "/bmp-js", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "bmp-js@^0.1.0", |
|
||||||
"name": "bmp-js", |
|
||||||
"escapedName": "bmp-js", |
|
||||||
"rawSpec": "^0.1.0", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^0.1.0" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/image-decode" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz", |
|
||||||
"_shasum": "e05a63f796a6c1ff25f4771ec7adadc148c07233", |
|
||||||
"_spec": "bmp-js@^0.1.0", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/image-decode", |
|
||||||
"author": { |
|
||||||
"name": "shaozilee", |
|
||||||
"email": "shaozilee@gmail.com" |
|
||||||
}, |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/shaozilee/bmp-js/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"dependencies": {}, |
|
||||||
"deprecated": false, |
|
||||||
"description": "A pure javascript BMP encoder and decoder", |
|
||||||
"devDependencies": {}, |
|
||||||
"homepage": "https://github.com/shaozilee/bmp-js#readme", |
|
||||||
"keywords": [ |
|
||||||
"bmp", |
|
||||||
"1bit", |
|
||||||
"4bit", |
|
||||||
"8bit", |
|
||||||
"16bit", |
|
||||||
"24bit", |
|
||||||
"32bit", |
|
||||||
"encoder", |
|
||||||
"decoder", |
|
||||||
"image", |
|
||||||
"javascript", |
|
||||||
"js" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "index.js", |
|
||||||
"name": "bmp-js", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git+https://github.com/shaozilee/bmp-js.git" |
|
||||||
}, |
|
||||||
"version": "0.1.0" |
|
||||||
} |
|
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
@ -1,33 +0,0 @@ |
|||||||
var fs = require("fs"); |
|
||||||
|
|
||||||
var coder = require("../index.js"); |
|
||||||
var bmps = ["./bit1", "./bit4", "./bit4_RLE", "./bit8", "./bit8_RLE", "./bit16_565", "./bit16_a444", "./bit16_a555", "./bit16_x444", "./bit16_x555", "./bit24", "./bit32", "./bit32_alpha"]; |
|
||||||
|
|
||||||
console.log("test bmp decoding and encoding..."); |
|
||||||
|
|
||||||
for(var b=0; b<bmps.length;b++){ |
|
||||||
var src =bmps[b]; |
|
||||||
console.log("----------------"+src+".bmp"); |
|
||||||
var bufferData = fs.readFileSync(src+".bmp"); |
|
||||||
var decoder = coder.decode(bufferData); |
|
||||||
console.log("width:",decoder.width); |
|
||||||
console.log("height",decoder.height); |
|
||||||
console.log("fileSize:",decoder.fileSize); |
|
||||||
|
|
||||||
|
|
||||||
//encode with 24bit
|
|
||||||
var encodeData = coder.encode(decoder); |
|
||||||
fs.writeFileSync(src+"_out.bmp", encodeData.data); |
|
||||||
} |
|
||||||
|
|
||||||
console.log("test bmp success!"); |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,4 +0,0 @@ |
|||||||
language: node_js |
|
||||||
node_js: |
|
||||||
- 0.8 |
|
||||||
- "0.10" |
|
@ -1,62 +0,0 @@ |
|||||||
buffer-equal |
|
||||||
============ |
|
||||||
|
|
||||||
Return whether two buffers are equal. |
|
||||||
|
|
||||||
[![build status](https://secure.travis-ci.org/substack/node-buffer-equal.png)](http://travis-ci.org/substack/node-buffer-equal) |
|
||||||
|
|
||||||
example |
|
||||||
======= |
|
||||||
|
|
||||||
``` js |
|
||||||
var bufferEqual = require('buffer-equal'); |
|
||||||
|
|
||||||
console.dir(bufferEqual( |
|
||||||
new Buffer([253,254,255]), |
|
||||||
new Buffer([253,254,255]) |
|
||||||
)); |
|
||||||
console.dir(bufferEqual( |
|
||||||
new Buffer('abc'), |
|
||||||
new Buffer('abcd') |
|
||||||
)); |
|
||||||
console.dir(bufferEqual( |
|
||||||
new Buffer('abc'), |
|
||||||
'abc' |
|
||||||
)); |
|
||||||
``` |
|
||||||
|
|
||||||
output: |
|
||||||
|
|
||||||
``` |
|
||||||
true |
|
||||||
false |
|
||||||
undefined |
|
||||||
``` |
|
||||||
|
|
||||||
methods |
|
||||||
======= |
|
||||||
|
|
||||||
``` js |
|
||||||
var bufferEqual = require('buffer-equal') |
|
||||||
``` |
|
||||||
|
|
||||||
bufferEqual(a, b) |
|
||||||
----------------- |
|
||||||
|
|
||||||
Return whether the two buffers `a` and `b` are equal. |
|
||||||
|
|
||||||
If `a` or `b` is not a buffer, return `undefined`. |
|
||||||
|
|
||||||
install |
|
||||||
======= |
|
||||||
|
|
||||||
With [npm](http://npmjs.org) do: |
|
||||||
|
|
||||||
``` |
|
||||||
npm install buffer-equal |
|
||||||
``` |
|
||||||
|
|
||||||
license |
|
||||||
======= |
|
||||||
|
|
||||||
MIT |
|
@ -1,14 +0,0 @@ |
|||||||
var bufferEqual = require('../'); |
|
||||||
|
|
||||||
console.dir(bufferEqual( |
|
||||||
new Buffer([253,254,255]), |
|
||||||
new Buffer([253,254,255]) |
|
||||||
)); |
|
||||||
console.dir(bufferEqual( |
|
||||||
new Buffer('abc'), |
|
||||||
new Buffer('abcd') |
|
||||||
)); |
|
||||||
console.dir(bufferEqual( |
|
||||||
new Buffer('abc'), |
|
||||||
'abc' |
|
||||||
)); |
|
@ -1,14 +0,0 @@ |
|||||||
var Buffer = require('buffer').Buffer; // for use with browserify
|
|
||||||
|
|
||||||
module.exports = function (a, b) { |
|
||||||
if (!Buffer.isBuffer(a)) return undefined; |
|
||||||
if (!Buffer.isBuffer(b)) return undefined; |
|
||||||
if (typeof a.equals === 'function') return a.equals(b); |
|
||||||
if (a.length !== b.length) return false; |
|
||||||
|
|
||||||
for (var i = 0; i < a.length; i++) { |
|
||||||
if (a[i] !== b[i]) return false; |
|
||||||
} |
|
||||||
|
|
||||||
return true; |
|
||||||
}; |
|
@ -1,62 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "buffer-equal@0.0.1", |
|
||||||
"_id": "buffer-equal@0.0.1", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha1-kbx0sR6kBbyRa8aqkI+q+ltKrEs=", |
|
||||||
"_location": "/buffer-equal", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "version", |
|
||||||
"registry": true, |
|
||||||
"raw": "buffer-equal@0.0.1", |
|
||||||
"name": "buffer-equal", |
|
||||||
"escapedName": "buffer-equal", |
|
||||||
"rawSpec": "0.0.1", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "0.0.1" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/readimage" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-0.0.1.tgz", |
|
||||||
"_shasum": "91bc74b11ea405bc916bc6aa908faafa5b4aac4b", |
|
||||||
"_spec": "buffer-equal@0.0.1", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/readimage", |
|
||||||
"author": { |
|
||||||
"name": "James Halliday", |
|
||||||
"email": "mail@substack.net", |
|
||||||
"url": "http://substack.net" |
|
||||||
}, |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/substack/node-buffer-equal/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"deprecated": false, |
|
||||||
"description": "return whether two buffers are equal", |
|
||||||
"devDependencies": { |
|
||||||
"tap": "0.2.4" |
|
||||||
}, |
|
||||||
"directories": { |
|
||||||
"example": "example", |
|
||||||
"test": "test" |
|
||||||
}, |
|
||||||
"engines": { |
|
||||||
"node": ">=0.4.0" |
|
||||||
}, |
|
||||||
"homepage": "https://github.com/substack/node-buffer-equal#readme", |
|
||||||
"keywords": [ |
|
||||||
"buffer", |
|
||||||
"equal" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "index.js", |
|
||||||
"name": "buffer-equal", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git://github.com/substack/node-buffer-equal.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"test": "tap test/*.js" |
|
||||||
}, |
|
||||||
"version": "0.0.1" |
|
||||||
} |
|
@ -1,35 +0,0 @@ |
|||||||
var bufferEqual = require('../'); |
|
||||||
var test = require('tap').test; |
|
||||||
|
|
||||||
test('equal', function (t) { |
|
||||||
var eq = bufferEqual( |
|
||||||
new Buffer([253,254,255]), |
|
||||||
new Buffer([253,254,255]) |
|
||||||
); |
|
||||||
t.strictEqual(eq, true); |
|
||||||
t.end(); |
|
||||||
}); |
|
||||||
|
|
||||||
test('not equal', function (t) { |
|
||||||
var eq = bufferEqual( |
|
||||||
new Buffer('abc'), |
|
||||||
new Buffer('abcd') |
|
||||||
); |
|
||||||
t.strictEqual(eq, false); |
|
||||||
t.end(); |
|
||||||
}); |
|
||||||
|
|
||||||
test('not equal not buffer', function (t) { |
|
||||||
var eq = bufferEqual( |
|
||||||
new Buffer('abc'), |
|
||||||
'abc' |
|
||||||
); |
|
||||||
t.strictEqual(eq, undefined); |
|
||||||
t.end(); |
|
||||||
}); |
|
||||||
|
|
||||||
test('equal not buffer', function (t) { |
|
||||||
var eq = bufferEqual('abc', 'abc'); |
|
||||||
t.strictEqual(eq, undefined); |
|
||||||
t.end(); |
|
||||||
}); |
|
@ -1,18 +0,0 @@ |
|||||||
This software is released under the MIT license: |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
||||||
this software and associated documentation files (the "Software"), to deal in |
|
||||||
the Software without restriction, including without limitation the rights to |
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
||||||
the Software, and to permit persons to whom the Software is furnished to do so, |
|
||||||
subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all |
|
||||||
copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
||||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
||||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
||||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
@ -1,5 +0,0 @@ |
|||||||
var tou8 = require('../'); |
|
||||||
var buf = new Buffer('whatever'); |
|
||||||
var a = tou8(buf); |
|
||||||
console.log(a.constructor.name); |
|
||||||
console.log(a); |
|
@ -1,11 +0,0 @@ |
|||||||
module.exports = function (buf) { |
|
||||||
if (!buf) return undefined; |
|
||||||
if (buf.constructor.name === 'Uint8Array' |
|
||||||
|| buf.constructor === Uint8Array) { |
|
||||||
return buf; |
|
||||||
} |
|
||||||
if (typeof buf === 'string') buf = Buffer(buf); |
|
||||||
var a = new Uint8Array(buf.length); |
|
||||||
for (var i = 0; i < buf.length; i++) a[i] = buf[i]; |
|
||||||
return a; |
|
||||||
}; |
|
@ -1,60 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "buffer-to-uint8array@^1.1.0", |
|
||||||
"_id": "buffer-to-uint8array@1.1.0", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha1-z29BKHwCL0WNp1LDkcGo1TXsX3I=", |
|
||||||
"_location": "/buffer-to-uint8array", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "buffer-to-uint8array@^1.1.0", |
|
||||||
"name": "buffer-to-uint8array", |
|
||||||
"escapedName": "buffer-to-uint8array", |
|
||||||
"rawSpec": "^1.1.0", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^1.1.0" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/image-decode" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/buffer-to-uint8array/-/buffer-to-uint8array-1.1.0.tgz", |
|
||||||
"_shasum": "cf6f41287c022f458da752c391c1a8d535ec5f72", |
|
||||||
"_spec": "buffer-to-uint8array@^1.1.0", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/image-decode", |
|
||||||
"author": { |
|
||||||
"name": "substack" |
|
||||||
}, |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/substack/buffer-to-uint8array/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"deprecated": false, |
|
||||||
"description": "convert a buffer (or string) to a Uint8Array", |
|
||||||
"devDependencies": { |
|
||||||
"tape": "^4.0.0" |
|
||||||
}, |
|
||||||
"directories": { |
|
||||||
"example": "example", |
|
||||||
"test": "test" |
|
||||||
}, |
|
||||||
"homepage": "https://github.com/substack/buffer-to-uint8array#readme", |
|
||||||
"keywords": [ |
|
||||||
"Uint8Array", |
|
||||||
"u8", |
|
||||||
"byte", |
|
||||||
"buffer", |
|
||||||
"typedarray" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "index.js", |
|
||||||
"name": "buffer-to-uint8array", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git://github.com/substack/buffer-to-uint8array.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"test": "tape test/*.js" |
|
||||||
}, |
|
||||||
"version": "1.1.0" |
|
||||||
} |
|
@ -1,37 +0,0 @@ |
|||||||
# buffer-to-uint8array |
|
||||||
|
|
||||||
convert a buffer (or string) to a Uint8Array |
|
||||||
|
|
||||||
# example |
|
||||||
|
|
||||||
``` js |
|
||||||
var tou8 = require('buffer-to-uint8array'); |
|
||||||
var buf = new Buffer('whatever'); |
|
||||||
var a = tou8(buf); |
|
||||||
console.log(a.constructor.name); |
|
||||||
console.log(a); |
|
||||||
``` |
|
||||||
|
|
||||||
# methods |
|
||||||
|
|
||||||
``` js |
|
||||||
var tou8 = require('buffer-to-uint8array') |
|
||||||
``` |
|
||||||
|
|
||||||
## var u = tou8(buf) |
|
||||||
|
|
||||||
Convert `buf`, a `Buffer` or `string` to a `Uint8Array`. |
|
||||||
|
|
||||||
If `buf` is already a Uint8Array, it will be returned. |
|
||||||
|
|
||||||
# install |
|
||||||
|
|
||||||
With [npm](https://npmjs.org) do: |
|
||||||
|
|
||||||
``` |
|
||||||
npm install buffer-to-uint8array |
|
||||||
``` |
|
||||||
|
|
||||||
# license |
|
||||||
|
|
||||||
MIT |
|
@ -1,10 +0,0 @@ |
|||||||
var test = require('tape'); |
|
||||||
var tou8 = require('../'); |
|
||||||
|
|
||||||
test('buffer to uint8', function (t) { |
|
||||||
t.plan(2); |
|
||||||
var buf = new Buffer('whatever'); |
|
||||||
var a = tou8(buf); |
|
||||||
t.equal(a.constructor.name, 'Uint8Array', 'constructor name'); |
|
||||||
t.equal(a.length, 8, 'buffer length'); |
|
||||||
}); |
|
@ -1,10 +0,0 @@ |
|||||||
var test = require('tape'); |
|
||||||
var tou8 = require('../'); |
|
||||||
|
|
||||||
test('string to uint8', function (t) { |
|
||||||
t.plan(2); |
|
||||||
var str = 'whatever'; |
|
||||||
var a = tou8(str); |
|
||||||
t.equal(a.constructor.name, 'Uint8Array', 'constructor name'); |
|
||||||
t.equal(a.length, 8, 'length'); |
|
||||||
}); |
|
@ -1,15 +0,0 @@ |
|||||||
var test = require('tape'); |
|
||||||
var tou8 = require('../'); |
|
||||||
|
|
||||||
test('uint8 to uint8', function (t) { |
|
||||||
t.plan(3); |
|
||||||
var a = new Uint8Array(8); |
|
||||||
var buf = Buffer('whatever'); |
|
||||||
for (var i = 0; i < buf.length; i++) a[i] = buf[i]; |
|
||||||
|
|
||||||
var b = tou8(a); |
|
||||||
|
|
||||||
t.equal(a, b, 'reference equality'); |
|
||||||
t.equal(a.constructor.name, 'Uint8Array', 'constructor name'); |
|
||||||
t.equal(a.length, 8, 'u8 length'); |
|
||||||
}); |
|
@ -1,2 +0,0 @@ |
|||||||
node_modules |
|
||||||
*.log |
|
@ -1,21 +0,0 @@ |
|||||||
## The MIT License (MIT) ## |
|
||||||
|
|
||||||
Copyright (c) 2013 Hugh Kennedy |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||||
of this software and associated documentation files (the "Software"), to deal |
|
||||||
in the Software without restriction, including without limitation the rights |
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||||
copies of the Software, and to permit persons to whom the Software is |
|
||||||
furnished to do so, subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in |
|
||||||
all copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
||||||
THE SOFTWARE. |
|
@ -1,17 +0,0 @@ |
|||||||
# clamp [![frozen](http://hughsk.github.io/stability-badges/dist/frozen.svg)](http://github.com/hughsk/stability-badges) # |
|
||||||
|
|
||||||
Clamp a value between two other values. It's as simple as modules come - saving |
|
||||||
keystrokes because I've had to write this function too many times. |
|
||||||
|
|
||||||
## Usage ## |
|
||||||
|
|
||||||
[![clamp](https://nodei.co/npm/clamp.png?mini=true)](https://nodei.co/npm/clamp) |
|
||||||
|
|
||||||
### `clamp(value, a, b)` ### |
|
||||||
|
|
||||||
Returns `value`, if it is between `a` and `b`. Otherwise, returns the number |
|
||||||
it's gone past. |
|
||||||
|
|
||||||
## License ## |
|
||||||
|
|
||||||
MIT. See [LICENSE.md](http://github.com/hughsk/clamp/blob/master/LICENSE.md) for details. |
|
@ -1,7 +0,0 @@ |
|||||||
module.exports = clamp |
|
||||||
|
|
||||||
function clamp(value, min, max) { |
|
||||||
return min < max |
|
||||||
? (value < min ? min : value > max ? max : value) |
|
||||||
: (value < max ? max : value > min ? min : value) |
|
||||||
} |
|
@ -1,61 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "clamp@^1.0.1", |
|
||||||
"_id": "clamp@1.0.1", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha1-ZqDmQBGBbjcZaCj9yMjBRzEshjQ=", |
|
||||||
"_location": "/clamp", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "clamp@^1.0.1", |
|
||||||
"name": "clamp", |
|
||||||
"escapedName": "clamp", |
|
||||||
"rawSpec": "^1.0.1", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^1.0.1" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/to-uint8" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/clamp/-/clamp-1.0.1.tgz", |
|
||||||
"_shasum": "66a0e64011816e37196828fdc8c8c147312c8634", |
|
||||||
"_spec": "clamp@^1.0.1", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/to-uint8", |
|
||||||
"author": { |
|
||||||
"name": "Hugh Kennedy", |
|
||||||
"email": "hughskennedy@gmail.com", |
|
||||||
"url": "http://github.com/hughsk" |
|
||||||
}, |
|
||||||
"browser": "index.js", |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/hughsk/clamp/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"dependencies": {}, |
|
||||||
"deprecated": false, |
|
||||||
"description": "Clamp a value between two other values", |
|
||||||
"devDependencies": { |
|
||||||
"tape": "~2.0.0" |
|
||||||
}, |
|
||||||
"homepage": "https://github.com/hughsk/clamp#readme", |
|
||||||
"keywords": [ |
|
||||||
"clamp", |
|
||||||
"math", |
|
||||||
"greater", |
|
||||||
"less", |
|
||||||
"than", |
|
||||||
"between" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "index.js", |
|
||||||
"name": "clamp", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git://github.com/hughsk/clamp.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"test": "node test" |
|
||||||
}, |
|
||||||
"version": "1.0.1" |
|
||||||
} |
|
@ -1,11 +0,0 @@ |
|||||||
var test = require('tape') |
|
||||||
var clamp = require('./') |
|
||||||
|
|
||||||
test('clamp', function(t) { |
|
||||||
t.equal(clamp(0, -100, 100), 0) |
|
||||||
t.equal(clamp(0, 100, 100), 100) |
|
||||||
t.equal(clamp(0, 100, -100), 0) |
|
||||||
t.equal(clamp(100, 0, 50), 50) |
|
||||||
t.equal(clamp(50, 100, 150), 100) |
|
||||||
t.end() |
|
||||||
}) |
|
@ -1,44 +0,0 @@ |
|||||||
{ |
|
||||||
"env": { |
|
||||||
"browser": true, |
|
||||||
"node": true, |
|
||||||
"commonjs": true, |
|
||||||
"es6": true |
|
||||||
}, |
|
||||||
"extends": "eslint:recommended", |
|
||||||
"rules": { |
|
||||||
"strict": 2, |
|
||||||
"indent": 0, |
|
||||||
"linebreak-style": 0, |
|
||||||
"quotes": 0, |
|
||||||
"semi": 0, |
|
||||||
"no-cond-assign": 1, |
|
||||||
"no-constant-condition": 1, |
|
||||||
"no-duplicate-case": 1, |
|
||||||
"no-empty": 1, |
|
||||||
"no-ex-assign": 1, |
|
||||||
"no-extra-boolean-cast": 1, |
|
||||||
"no-extra-semi": 1, |
|
||||||
"no-fallthrough": 1, |
|
||||||
"no-func-assign": 1, |
|
||||||
"no-global-assign": 1, |
|
||||||
"no-implicit-globals": 2, |
|
||||||
"no-inner-declarations": ["error", "functions"], |
|
||||||
"no-irregular-whitespace": 2, |
|
||||||
"no-loop-func": 1, |
|
||||||
"no-magic-numbers": ["warn", { "ignore": [1, 0, -1], "ignoreArrayIndexes": true}], |
|
||||||
"no-multi-str": 1, |
|
||||||
"no-mixed-spaces-and-tabs": 1, |
|
||||||
"no-proto": 1, |
|
||||||
"no-sequences": 1, |
|
||||||
"no-throw-literal": 1, |
|
||||||
"no-unmodified-loop-condition": 1, |
|
||||||
"no-useless-call": 1, |
|
||||||
"no-void": 1, |
|
||||||
"no-with": 2, |
|
||||||
"wrap-iife": 1, |
|
||||||
"no-redeclare": 1, |
|
||||||
"no-unused-vars": ["error", { "vars": "all", "args": "none" }], |
|
||||||
"no-sparse-arrays": 1 |
|
||||||
} |
|
||||||
} |
|
@ -1,13 +0,0 @@ |
|||||||
sudo: false |
|
||||||
language: node_js |
|
||||||
node_js: |
|
||||||
- "6" |
|
||||||
- "5" |
|
||||||
- "4" |
|
||||||
- "0.12" |
|
||||||
- "0.10" |
|
||||||
matrix: |
|
||||||
fast_finish: true |
|
||||||
allow_failures: |
|
||||||
- node_js: "0.10" |
|
||||||
- node_js: "0.12" |
|
@ -1,24 +0,0 @@ |
|||||||
'use strict' |
|
||||||
|
|
||||||
module.exports = function clip (pixels, shape, rect) { |
|
||||||
var stride = shape[2] || 4 |
|
||||||
var row = shape[0], |
|
||||||
col = shape[1] || Math.floor(pixels.length / stride / row) |
|
||||||
var x = rect[0], |
|
||||||
y = rect[1] || 0, |
|
||||||
w = rect[2] || row - x, |
|
||||||
h = rect[3] || col - y |
|
||||||
|
|
||||||
var result = Array(w * stride * h) |
|
||||||
|
|
||||||
var off = y * row * stride + x * stride |
|
||||||
for (var j = 0; j < h; j++) { |
|
||||||
for (var i = 0; i < w; i++) { |
|
||||||
for (var k = 0; k < stride; k++) { |
|
||||||
result[j * w * stride + i * stride + k] = pixels[off + j * row * stride + i * stride + k] |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return result |
|
||||||
} |
|
@ -1,54 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "clip-pixels@^1.0.1", |
|
||||||
"_id": "clip-pixels@1.0.1", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha512-nJ22fZvCwkJfMppkOEE7GciLX08rDnVzEJ+U46kBFZtwNzH2V4tNxMWa9Tc365WspCxy1c3NtGJ5EeT4SgjmCA==", |
|
||||||
"_location": "/clip-pixels", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "clip-pixels@^1.0.1", |
|
||||||
"name": "clip-pixels", |
|
||||||
"escapedName": "clip-pixels", |
|
||||||
"rawSpec": "^1.0.1", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^1.0.1" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/image-pixels" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/clip-pixels/-/clip-pixels-1.0.1.tgz", |
|
||||||
"_shasum": "c6304c5b82f6a5b555f1a5990a1cde84077614f8", |
|
||||||
"_spec": "clip-pixels@^1.0.1", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/image-pixels", |
|
||||||
"author": { |
|
||||||
"name": "dy" |
|
||||||
}, |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/dy/clip-pixels/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"deprecated": false, |
|
||||||
"description": "Slice rectangle from pixels array", |
|
||||||
"homepage": "https://github.com/dy/clip-pixels#readme", |
|
||||||
"keywords": [ |
|
||||||
"clip", |
|
||||||
"slice", |
|
||||||
"ndarray", |
|
||||||
"flip-pixels", |
|
||||||
"pxls", |
|
||||||
"pixels" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "index.js", |
|
||||||
"name": "clip-pixels", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git+https://github.com/dy/clip-pixels.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"test": "node test" |
|
||||||
}, |
|
||||||
"version": "1.0.1" |
|
||||||
} |
|
@ -1,22 +0,0 @@ |
|||||||
[![Build Status](https://travis-ci.org/dy/clip-pixels.svg?branch=master)](https://travis-ci.org/dy/clip-pixels) |
|
||||||
|
|
||||||
Slice rectangle from an array with pixels. |
|
||||||
|
|
||||||
### `clip(arr, shape=[w, h?, channels=4], rect=[x, y?, w?, h?])` |
|
||||||
|
|
||||||
```js |
|
||||||
var clip = require('clip-pixels') |
|
||||||
|
|
||||||
var pixels = [ |
|
||||||
0, 1, 0, |
|
||||||
1, 1, 1, |
|
||||||
0, 1, 0 |
|
||||||
] |
|
||||||
pixels = clip(pixels, [3, 3, 1], [1, 0, 2, 3]) |
|
||||||
|
|
||||||
/* |
|
||||||
1, 0, |
|
||||||
1, 1, |
|
||||||
1, 0 |
|
||||||
*/ |
|
||||||
``` |
|
@ -1,31 +0,0 @@ |
|||||||
'use strict' |
|
||||||
|
|
||||||
var clip = require('./') |
|
||||||
var a = require('assert') |
|
||||||
|
|
||||||
|
|
||||||
var pixels = [ |
|
||||||
0, 1, 0, |
|
||||||
1, 1, 1, |
|
||||||
0, 1, 0 |
|
||||||
] |
|
||||||
a.deepEqual(clip(pixels, [3, 3, 1], [1, 0, 2, 3]), |
|
||||||
[ |
|
||||||
1, 0, |
|
||||||
1, 1, |
|
||||||
1, 0 |
|
||||||
]) |
|
||||||
|
|
||||||
|
|
||||||
// short args
|
|
||||||
var pixels = [ |
|
||||||
0,0,0,0, 1,1,1,1, 0,0,0,0, |
|
||||||
1,1,1,1, 1,1,1,1, 1,1,1,1, |
|
||||||
0,0,0,0, 1,1,1,1, 0,0,0,0 |
|
||||||
] |
|
||||||
a.deepEqual(clip(pixels, [3], [1, 0]), |
|
||||||
[ |
|
||||||
1,1,1,1, 0,0,0,0, |
|
||||||
1,1,1,1, 1,1,1,1, |
|
||||||
1,1,1,1, 0,0,0,0 |
|
||||||
]) |
|
@ -1,21 +0,0 @@ |
|||||||
The MIT License (MIT) |
|
||||||
|
|
||||||
Copyright (c) 2014-2015 The Compute.io Authors. All rights reserved. |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||||
of this software and associated documentation files (the "Software"), to deal |
|
||||||
in the Software without restriction, including without limitation the rights |
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||||
copies of the Software, and to permit persons to whom the Software is |
|
||||||
furnished to do so, subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all |
|
||||||
copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||||
SOFTWARE. |
|
@ -1,137 +0,0 @@ |
|||||||
dims |
|
||||||
=== |
|
||||||
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependencies][dependencies-image]][dependencies-url] |
|
||||||
|
|
||||||
> Computes dimensions for arrays and matrices. |
|
||||||
|
|
||||||
|
|
||||||
## Installation |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ npm install compute-dims |
|
||||||
``` |
|
||||||
|
|
||||||
For use in the browser, use [browserify](https://github.com/substack/node-browserify). |
|
||||||
|
|
||||||
|
|
||||||
## Usage |
|
||||||
|
|
||||||
|
|
||||||
``` javascript |
|
||||||
var dims = require( 'compute-dims' ); |
|
||||||
``` |
|
||||||
|
|
||||||
#### dims( x[, max] ) |
|
||||||
|
|
||||||
Computes dimensions of `x`. `x` may be either an [`array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) (including nested `arrays`) or a [`matrix`](https://github.com/dstructs/matrix). |
|
||||||
|
|
||||||
``` javascript |
|
||||||
var matrix = require( 'dstructs-matrix' ), |
|
||||||
data, |
|
||||||
d; |
|
||||||
|
|
||||||
data = [ 1, 2 ]; |
|
||||||
d = dims( data ); |
|
||||||
// returns [2] |
|
||||||
|
|
||||||
data = [ [1,2], [1,2] ]; |
|
||||||
d = dims( data ); |
|
||||||
// returns [2,2] |
|
||||||
|
|
||||||
data = matrix( [1,2,3,4], [2,2] ) |
|
||||||
d = dims( data ); |
|
||||||
// returns [2,2] |
|
||||||
``` |
|
||||||
|
|
||||||
If an `array` element has a dimension inconsistent with other elements, the function returns `null`. |
|
||||||
|
|
||||||
``` javascript |
|
||||||
data = [ [1,2], [1] ]; |
|
||||||
d = dims( data ); |
|
||||||
// returns null |
|
||||||
``` |
|
||||||
|
|
||||||
To limit the number of dimensions returned, set the `max` option. |
|
||||||
|
|
||||||
``` javascript |
|
||||||
data = [ [[1,2], [3,4]] ]; // 1x2x2 |
|
||||||
d = dims( data, 2 ); |
|
||||||
// returns [1,2] |
|
||||||
|
|
||||||
data = [ [[1,2], [3,4,5,6,7,8]] ]; |
|
||||||
d = dims( data ); |
|
||||||
// returns null |
|
||||||
|
|
||||||
d = dims( data, 2 ); |
|
||||||
// returns [1,2] |
|
||||||
|
|
||||||
data = matrix( [1,2,3,4], [2,2] ); |
|
||||||
d = dims( data, 1 ); |
|
||||||
// returns [2] |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
## Examples |
|
||||||
|
|
||||||
To run the example code from the top-level application directory, |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ node ./examples/index.js |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
## Tests |
|
||||||
|
|
||||||
### Unit |
|
||||||
|
|
||||||
Unit tests use the [Mocha](http://mochajs.org) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory: |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make test |
|
||||||
``` |
|
||||||
|
|
||||||
All new feature development should have corresponding unit tests to validate correct functionality. |
|
||||||
|
|
||||||
|
|
||||||
### Test Coverage |
|
||||||
|
|
||||||
This repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory: |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make test-cov |
|
||||||
``` |
|
||||||
|
|
||||||
Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report, |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make view-cov |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
--- |
|
||||||
## License |
|
||||||
|
|
||||||
[MIT license](http://opensource.org/licenses/MIT). |
|
||||||
|
|
||||||
|
|
||||||
## Copyright |
|
||||||
|
|
||||||
Copyright © 2014-2015. The [Compute.io](https://github.com/compute-io) Authors. |
|
||||||
|
|
||||||
[npm-image]: http://img.shields.io/npm/v/compute-dims.svg |
|
||||||
[npm-url]: https://npmjs.org/package/compute-dims |
|
||||||
|
|
||||||
[travis-image]: http://img.shields.io/travis/compute-io/dims/master.svg |
|
||||||
[travis-url]: https://travis-ci.org/compute-io/dims |
|
||||||
|
|
||||||
[coveralls-image]: https://img.shields.io/coveralls/compute-io/dims/master.svg |
|
||||||
[coveralls-url]: https://coveralls.io/r/compute-io/dims?branch=master |
|
||||||
|
|
||||||
[dependencies-image]: http://img.shields.io/david/compute-io/dims.svg |
|
||||||
[dependencies-url]: https://david-dm.org/compute-io/dims |
|
||||||
|
|
||||||
[dev-dependencies-image]: http://img.shields.io/david/dev/compute-io/dims.svg |
|
||||||
[dev-dependencies-url]: https://david-dm.org/dev/compute-io/dims |
|
||||||
|
|
||||||
[github-issues-image]: http://img.shields.io/github/issues/compute-io/dims.svg |
|
||||||
[github-issues-url]: https://github.com/compute-io/dims/issues |
|
@ -1,114 +0,0 @@ |
|||||||
'use strict'; |
|
||||||
|
|
||||||
// MODULES //
|
|
||||||
|
|
||||||
var isPositiveInteger = require( 'validate.io-positive-integer' ), |
|
||||||
isArray = require( 'validate.io-array' ), |
|
||||||
ndarrayLike = require( 'validate.io-ndarray-like' ), |
|
||||||
createCopy = require( 'utils-copy' ); |
|
||||||
|
|
||||||
|
|
||||||
// DIMS //
|
|
||||||
|
|
||||||
/** |
|
||||||
* FUNCTION: dims( x, d, max ) |
|
||||||
* Computes array dimensions. |
|
||||||
* |
|
||||||
* @private |
|
||||||
* @param {Array} arr - input array |
|
||||||
* @param {Array} d - dimensions array |
|
||||||
* @param {Number} max - max number of dimensions |
|
||||||
* @returns {Array} dimensions array |
|
||||||
*/ |
|
||||||
function dims( arr, d, max ) { |
|
||||||
if ( max && d.length === max ) { |
|
||||||
return; |
|
||||||
} |
|
||||||
if ( !isArray( arr[0] ) ) { |
|
||||||
return; |
|
||||||
} |
|
||||||
d.push( arr[0].length ); |
|
||||||
dims( arr[ 0 ], d, max ); |
|
||||||
} // end FUNCTION dims()
|
|
||||||
|
|
||||||
/** |
|
||||||
* FUNCTION: check( arr, d ) |
|
||||||
* Checks that all array elements have the same dimensions. |
|
||||||
* |
|
||||||
* @private |
|
||||||
* @param {Array} arr - input array |
|
||||||
* @param {Array} d - dimensions array |
|
||||||
* @returns {Boolean} boolean indicating if all array elements have the same dimensions |
|
||||||
*/ |
|
||||||
function check( arr, d ) { |
|
||||||
var len = arr.length, |
|
||||||
dim = d.shift(), |
|
||||||
nDims = d.length, |
|
||||||
val, |
|
||||||
flg; |
|
||||||
|
|
||||||
for ( var i = 0; i < len; i++ ) { |
|
||||||
val = arr[ i ]; |
|
||||||
if ( !isArray( val ) || val.length !== dim ) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
if ( nDims ) { |
|
||||||
flg = check( val, d.slice() ); |
|
||||||
if ( !flg ) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return true; |
|
||||||
} // end FUNCTION check()
|
|
||||||
|
|
||||||
/** |
|
||||||
* FUNCTION: compute( x[, max] ) |
|
||||||
* Computes dimensions. |
|
||||||
* |
|
||||||
* @param {Array} x - input object |
|
||||||
* @param {Number} [max] - limits the number of dimensions returned |
|
||||||
* @returns {Array|null} array of dimensions or null |
|
||||||
*/ |
|
||||||
function compute( x, max ) { |
|
||||||
|
|
||||||
var d, flg; |
|
||||||
|
|
||||||
if ( arguments.length > 1 ) { |
|
||||||
if ( !isPositiveInteger( max ) ) { |
|
||||||
throw new TypeError( 'dims()::invalid input argument. `max` option must be a positive integer.' ); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if ( ndarrayLike( x ) === true ) { |
|
||||||
d = createCopy( x.shape ); |
|
||||||
if ( max && max <= d.length ) { |
|
||||||
d.length = max; |
|
||||||
} |
|
||||||
return d; |
|
||||||
} |
|
||||||
|
|
||||||
if ( isArray( x ) ) { |
|
||||||
// [0] Initialize the dimensions array:
|
|
||||||
d = [ x.length ]; |
|
||||||
|
|
||||||
// [1] Recursively determine array dimensions:
|
|
||||||
dims( x, d, max ); |
|
||||||
|
|
||||||
// [2] Check that all array element dimensions are consistent...
|
|
||||||
if ( d.length > 1 ) { |
|
||||||
flg = check( x, d.slice( 1 ) ); |
|
||||||
if ( !flg ) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
return d; |
|
||||||
} |
|
||||||
|
|
||||||
throw new TypeError( 'dims()::invalid input argument. Must provide an array, matrix or ndarray.' ); |
|
||||||
} // end FUNCTION compute()
|
|
||||||
|
|
||||||
|
|
||||||
// EXPORTS //
|
|
||||||
|
|
||||||
module.exports = compute; |
|
@ -1,83 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "compute-dims@^1.1.0", |
|
||||||
"_id": "compute-dims@1.1.0", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha512-YHMiIKjH/8Eom8zATk3g8/lH3HxGCZcVQyEfEoVrfWI7od/WRpTgRGShnei3jArYSx77mQqPxZNokjGHCdLfxg==", |
|
||||||
"_location": "/compute-dims", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "compute-dims@^1.1.0", |
|
||||||
"name": "compute-dims", |
|
||||||
"escapedName": "compute-dims", |
|
||||||
"rawSpec": "^1.1.0", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^1.1.0" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/pxls" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/compute-dims/-/compute-dims-1.1.0.tgz", |
|
||||||
"_shasum": "6d5b712929b6c531af3b4d580ed5adacbbd77e0c", |
|
||||||
"_spec": "compute-dims@^1.1.0", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/pxls", |
|
||||||
"author": { |
|
||||||
"name": "Athan Reines", |
|
||||||
"email": "kgryte@gmail.com" |
|
||||||
}, |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/compute-io/dims/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"contributors": [ |
|
||||||
{ |
|
||||||
"name": "Athan Reines", |
|
||||||
"email": "kgryte@gmail.com" |
|
||||||
} |
|
||||||
], |
|
||||||
"dependencies": { |
|
||||||
"utils-copy": "^1.0.0", |
|
||||||
"validate.io-array": "^1.0.6", |
|
||||||
"validate.io-matrix-like": "^1.0.2", |
|
||||||
"validate.io-ndarray-like": "^1.0.0", |
|
||||||
"validate.io-positive-integer": "^1.0.0" |
|
||||||
}, |
|
||||||
"deprecated": false, |
|
||||||
"description": "Computes array dimensions.", |
|
||||||
"devDependencies": { |
|
||||||
"chai": "3.x.x", |
|
||||||
"coveralls": "^2.11.1", |
|
||||||
"dstructs-matrix": "^2.0.0", |
|
||||||
"istanbul": "^0.3.0", |
|
||||||
"jshint": "2.x.x", |
|
||||||
"jshint-stylish": "2.x.x", |
|
||||||
"mocha": "2.x.x" |
|
||||||
}, |
|
||||||
"homepage": "https://github.com/compute-io/dims#readme", |
|
||||||
"keywords": [ |
|
||||||
"compute.io", |
|
||||||
"compute", |
|
||||||
"computation", |
|
||||||
"array", |
|
||||||
"utilities", |
|
||||||
"utils", |
|
||||||
"dimensions", |
|
||||||
"size", |
|
||||||
"shape", |
|
||||||
"dims" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "./lib", |
|
||||||
"name": "compute-dims", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git://github.com/compute-io/dims.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"coveralls": "istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coveralls/coverage --report lcovonly -- -R spec && cat ./reports/coveralls/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./reports/coveralls", |
|
||||||
"test": "mocha", |
|
||||||
"test-cov": "istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec" |
|
||||||
}, |
|
||||||
"version": "1.1.0" |
|
||||||
} |
|
@ -1,21 +0,0 @@ |
|||||||
The MIT License (MIT) |
|
||||||
|
|
||||||
Copyright (c) 2015-2016 The Compute.io Authors. |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||||
of this software and associated documentation files (the "Software"), to deal |
|
||||||
in the Software without restriction, including without limitation the rights |
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||||
copies of the Software, and to permit persons to whom the Software is |
|
||||||
furnished to do so, subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all |
|
||||||
copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||||
SOFTWARE. |
|
@ -1,130 +0,0 @@ |
|||||||
Max Uint32 |
|
||||||
=== |
|
||||||
[![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url] [![Dependencies][dependencies-image]][dependencies-url] |
|
||||||
|
|
||||||
> Maximum unsigned 32-bit integer. |
|
||||||
|
|
||||||
|
|
||||||
## Installation |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ npm install const-max-uint32 |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
## Usage |
|
||||||
|
|
||||||
``` javascript |
|
||||||
var MAX_UINT32 = require( 'const-max-uint32' ); |
|
||||||
``` |
|
||||||
|
|
||||||
#### MAX_UINT32 |
|
||||||
|
|
||||||
Maximum unsigned 32-bit `integer`. |
|
||||||
|
|
||||||
``` javascript |
|
||||||
MAX_UINT32 === Math.pow( 2, 32 ) - 1; |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
## Notes |
|
||||||
|
|
||||||
- `MAX_UINT32` is the maximum `array` length. |
|
||||||
|
|
||||||
|
|
||||||
## Examples |
|
||||||
|
|
||||||
``` javascript |
|
||||||
var MAX_UINT32 = require( 'const-max-uint32' ); |
|
||||||
|
|
||||||
console.log( MAX_UINT32 ); |
|
||||||
// returns 4294967295 |
|
||||||
``` |
|
||||||
|
|
||||||
To run the example code from the top-level application directory, |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ node ./examples/index.js |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
--- |
|
||||||
## Tests |
|
||||||
|
|
||||||
### Unit |
|
||||||
|
|
||||||
This repository uses [tape][tape] for unit tests. To run the tests, execute the following command in the top-level application directory: |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make test |
|
||||||
``` |
|
||||||
|
|
||||||
All new feature development should have corresponding unit tests to validate correct functionality. |
|
||||||
|
|
||||||
|
|
||||||
### Test Coverage |
|
||||||
|
|
||||||
This repository uses [Istanbul][istanbul] as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory: |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make test-cov |
|
||||||
``` |
|
||||||
|
|
||||||
Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report, |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make view-cov |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
### Browser Support |
|
||||||
|
|
||||||
This repository uses [Testling][testling] for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory: |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make test-browsers |
|
||||||
``` |
|
||||||
|
|
||||||
To view the tests in a local web browser, |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make view-browser-tests |
|
||||||
``` |
|
||||||
|
|
||||||
<!-- [![browser support][browsers-image]][browsers-url] --> |
|
||||||
|
|
||||||
|
|
||||||
--- |
|
||||||
## License |
|
||||||
|
|
||||||
[MIT license](http://opensource.org/licenses/MIT). |
|
||||||
|
|
||||||
|
|
||||||
## Copyright |
|
||||||
|
|
||||||
Copyright © 2015-2016. The [Compute.io][compute-io] Authors. |
|
||||||
|
|
||||||
|
|
||||||
[npm-image]: http://img.shields.io/npm/v/const-max-uint32.svg |
|
||||||
[npm-url]: https://npmjs.org/package/const-max-uint32 |
|
||||||
|
|
||||||
[build-image]: http://img.shields.io/travis/const-io/max-uint32/master.svg |
|
||||||
[build-url]: https://travis-ci.org/const-io/max-uint32 |
|
||||||
|
|
||||||
[coverage-image]: https://img.shields.io/codecov/c/github/const-io/max-uint32/master.svg |
|
||||||
[coverage-url]: https://codecov.io/github/const-io/max-uint32?branch=master |
|
||||||
|
|
||||||
[dependencies-image]: http://img.shields.io/david/const-io/max-uint32.svg |
|
||||||
[dependencies-url]: https://david-dm.org/const-io/max-uint32 |
|
||||||
|
|
||||||
[dev-dependencies-image]: http://img.shields.io/david/dev/const-io/max-uint32.svg |
|
||||||
[dev-dependencies-url]: https://david-dm.org/dev/const-io/max-uint32 |
|
||||||
|
|
||||||
[github-issues-image]: http://img.shields.io/github/issues/const-io/max-uint32.svg |
|
||||||
[github-issues-url]: https://github.com/const-io/max-uint32/issues |
|
||||||
|
|
||||||
[tape]: https://github.com/substack/tape |
|
||||||
[istanbul]: https://github.com/gotwarlost/istanbul |
|
||||||
[testling]: https://ci.testling.com |
|
||||||
|
|
||||||
[compute-io]: https://github.com/compute-io |
|
@ -1,5 +0,0 @@ |
|||||||
'use strict'; |
|
||||||
|
|
||||||
// EXPORTS //
|
|
||||||
|
|
||||||
module.exports = 4294967295; // 2**32 - 1
|
|
@ -1,104 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "const-max-uint32@^1.0.2", |
|
||||||
"_id": "const-max-uint32@1.0.2", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha1-8Am7YjDmeO2HTdLWqc2ePL+rtnY=", |
|
||||||
"_location": "/const-max-uint32", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "const-max-uint32@^1.0.2", |
|
||||||
"name": "const-max-uint32", |
|
||||||
"escapedName": "const-max-uint32", |
|
||||||
"rawSpec": "^1.0.2", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^1.0.2" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/validate.io-array-like" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/const-max-uint32/-/const-max-uint32-1.0.2.tgz", |
|
||||||
"_shasum": "f009bb6230e678ed874dd2d6a9cd9e3cbfabb676", |
|
||||||
"_spec": "const-max-uint32@^1.0.2", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/validate.io-array-like", |
|
||||||
"author": { |
|
||||||
"name": "Athan Reines", |
|
||||||
"email": "kgryte@gmail.com" |
|
||||||
}, |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/const-io/max-uint32/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"contributors": [ |
|
||||||
{ |
|
||||||
"name": "Athan Reines", |
|
||||||
"email": "kgryte@gmail.com" |
|
||||||
} |
|
||||||
], |
|
||||||
"dependencies": {}, |
|
||||||
"deprecated": false, |
|
||||||
"description": "Maximum unsigned 32-bit integer.", |
|
||||||
"devDependencies": { |
|
||||||
"browserify": "12.x.x", |
|
||||||
"codecov": "1.x.x", |
|
||||||
"istanbul": "^0.4.1", |
|
||||||
"jshint": "2.x.x", |
|
||||||
"jshint-stylish": "2.x.x", |
|
||||||
"math-power": "^1.0.0", |
|
||||||
"tap-spec": "4.x.x", |
|
||||||
"tape": "4.x.x", |
|
||||||
"testling": "1.x.x" |
|
||||||
}, |
|
||||||
"homepage": "https://github.com/const-io/max-uint32#readme", |
|
||||||
"keywords": [ |
|
||||||
"compute.io", |
|
||||||
"compute", |
|
||||||
"computation", |
|
||||||
"max", |
|
||||||
"array", |
|
||||||
"length", |
|
||||||
"uint32", |
|
||||||
"integer", |
|
||||||
"unsigned", |
|
||||||
"32-bit", |
|
||||||
"const", |
|
||||||
"const-io", |
|
||||||
"const.io", |
|
||||||
"constant" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "./lib", |
|
||||||
"name": "const-max-uint32", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git://github.com/const-io/max-uint32.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"coverage": "istanbul cover --dir ./reports/codecov/coverage --report lcovonly tape -- \"./test/*.js\" && cat ./reports/codecov/coverage/lcov.info | codecov && rm -rf ./reports/codecov", |
|
||||||
"test": "if [ \"${TRAVIS}\" ]; then npm run test-ci; else npm run test-local; fi", |
|
||||||
"test-browsers": "browserify ./test/*.js | testling | tap-spec", |
|
||||||
"test-ci": "npm run test-local && xvfb-run npm run test-browsers", |
|
||||||
"test-cov": "istanbul cover --dir ./reports/coverage --report lcov tape -- \"./test/*.js\"", |
|
||||||
"test-local": "tape \"./test/*.js\" | tap-spec" |
|
||||||
}, |
|
||||||
"testling": { |
|
||||||
"files": [ |
|
||||||
"test/*.js" |
|
||||||
], |
|
||||||
"browsers": [ |
|
||||||
"iexplore/6.0..latest", |
|
||||||
"firefox/3.0..latest", |
|
||||||
"firefox/nightly", |
|
||||||
"chrome/4.0..latest", |
|
||||||
"chrome/canary", |
|
||||||
"opera/10.0..latest", |
|
||||||
"opera/next", |
|
||||||
"safari/4.0..latest", |
|
||||||
"ipad/6.0..latest", |
|
||||||
"iphone/6.0..latest", |
|
||||||
"android-browser/4.2..latest" |
|
||||||
] |
|
||||||
}, |
|
||||||
"version": "1.0.2" |
|
||||||
} |
|
@ -1,21 +0,0 @@ |
|||||||
The MIT License (MIT) |
|
||||||
|
|
||||||
Copyright (c) 2016 The Compute.io Authors. |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||||
of this software and associated documentation files (the "Software"), to deal |
|
||||||
in the Software without restriction, including without limitation the rights |
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||||
copies of the Software, and to permit persons to whom the Software is |
|
||||||
furnished to do so, subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all |
|
||||||
copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||||
SOFTWARE. |
|
@ -1,124 +0,0 @@ |
|||||||
Positive Infinity |
|
||||||
=== |
|
||||||
[![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url] [![Dependencies][dependencies-image]][dependencies-url] |
|
||||||
|
|
||||||
> Positive infinity. |
|
||||||
|
|
||||||
|
|
||||||
## Installation |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ npm install const-pinf-float64 |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
## Usage |
|
||||||
|
|
||||||
``` javascript |
|
||||||
var pinf = require( 'const-pinf-float64' ); |
|
||||||
``` |
|
||||||
|
|
||||||
#### pinf |
|
||||||
|
|
||||||
Positive infinity. |
|
||||||
|
|
||||||
``` javascript |
|
||||||
pinf === Number.POSITIVE_INFINITY; |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
## Examples |
|
||||||
|
|
||||||
``` javascript |
|
||||||
var pinf = require( 'const-pinf-float64' ); |
|
||||||
|
|
||||||
console.log( pinf ); |
|
||||||
``` |
|
||||||
|
|
||||||
To run the example code from the top-level application directory, |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ node ./examples/index.js |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
--- |
|
||||||
## Tests |
|
||||||
|
|
||||||
### Unit |
|
||||||
|
|
||||||
This repository uses [tape][tape] for unit tests. To run the tests, execute the following command in the top-level application directory: |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make test |
|
||||||
``` |
|
||||||
|
|
||||||
All new feature development should have corresponding unit tests to validate correct functionality. |
|
||||||
|
|
||||||
|
|
||||||
### Test Coverage |
|
||||||
|
|
||||||
This repository uses [Istanbul][istanbul] as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory: |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make test-cov |
|
||||||
``` |
|
||||||
|
|
||||||
Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report, |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make view-cov |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
### Browser Support |
|
||||||
|
|
||||||
This repository uses [Testling][testling] for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory: |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make test-browsers |
|
||||||
``` |
|
||||||
|
|
||||||
To view the tests in a local web browser, |
|
||||||
|
|
||||||
``` bash |
|
||||||
$ make view-browser-tests |
|
||||||
``` |
|
||||||
|
|
||||||
<!-- [![browser support][browsers-image]][browsers-url] --> |
|
||||||
|
|
||||||
|
|
||||||
--- |
|
||||||
## License |
|
||||||
|
|
||||||
[MIT license](http://opensource.org/licenses/MIT). |
|
||||||
|
|
||||||
|
|
||||||
## Copyright |
|
||||||
|
|
||||||
Copyright © 2016. The [Compute.io][compute-io] Authors.. |
|
||||||
|
|
||||||
|
|
||||||
[npm-image]: http://img.shields.io/npm/v/const-pinf-float64.svg |
|
||||||
[npm-url]: https://npmjs.org/package/const-pinf-float64 |
|
||||||
|
|
||||||
[build-image]: http://img.shields.io/travis/const-io/pinf-float64/master.svg |
|
||||||
[build-url]: https://travis-ci.org/const-io/pinf-float64 |
|
||||||
|
|
||||||
[coverage-image]: https://img.shields.io/codecov/c/github/const-io/pinf-float64/master.svg |
|
||||||
[coverage-url]: https://codecov.io/github/const-io/pinf-float64?branch=master |
|
||||||
|
|
||||||
[dependencies-image]: http://img.shields.io/david/const-io/pinf-float64.svg |
|
||||||
[dependencies-url]: https://david-dm.org/const-io/pinf-float64 |
|
||||||
|
|
||||||
[dev-dependencies-image]: http://img.shields.io/david/dev/const-io/pinf-float64.svg |
|
||||||
[dev-dependencies-url]: https://david-dm.org/dev/const-io/pinf-float64 |
|
||||||
|
|
||||||
[github-issues-image]: http://img.shields.io/github/issues/const-io/pinf-float64.svg |
|
||||||
[github-issues-url]: https://github.com/const-io/pinf-float64/issues |
|
||||||
|
|
||||||
[tape]: https://github.com/substack/tape |
|
||||||
[istanbul]: https://github.com/gotwarlost/istanbul |
|
||||||
[testling]: https://ci.testling.com |
|
||||||
|
|
||||||
[compute-io]: https://github.com/compute-io/ |
|
@ -1,5 +0,0 @@ |
|||||||
'use strict'; |
|
||||||
|
|
||||||
// EXPORTS //
|
|
||||||
|
|
||||||
module.exports = Number.POSITIVE_INFINITY; |
|
@ -1,102 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "const-pinf-float64@^1.0.0", |
|
||||||
"_id": "const-pinf-float64@1.0.0", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha1-9u+w15+cCYbT558pI6v5twtj1yY=", |
|
||||||
"_location": "/const-pinf-float64", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "range", |
|
||||||
"registry": true, |
|
||||||
"raw": "const-pinf-float64@^1.0.0", |
|
||||||
"name": "const-pinf-float64", |
|
||||||
"escapedName": "const-pinf-float64", |
|
||||||
"rawSpec": "^1.0.0", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "^1.0.0" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"/utils-copy" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/const-pinf-float64/-/const-pinf-float64-1.0.0.tgz", |
|
||||||
"_shasum": "f6efb0d79f9c0986d3e79f2923abf9b70b63d726", |
|
||||||
"_spec": "const-pinf-float64@^1.0.0", |
|
||||||
"_where": "/home/sigonasr2/divar/server/node_modules/utils-copy", |
|
||||||
"author": { |
|
||||||
"name": "Athan Reines", |
|
||||||
"email": "kgryte@gmail.com" |
|
||||||
}, |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/const-io/pinf-float64/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"contributors": [ |
|
||||||
{ |
|
||||||
"name": "Athan Reines", |
|
||||||
"email": "kgryte@gmail.com" |
|
||||||
} |
|
||||||
], |
|
||||||
"dependencies": {}, |
|
||||||
"deprecated": false, |
|
||||||
"description": "Positive infinity.", |
|
||||||
"devDependencies": { |
|
||||||
"browserify": "12.x.x", |
|
||||||
"codecov": "1.x.x", |
|
||||||
"istanbul": "^0.4.1", |
|
||||||
"jshint": "2.x.x", |
|
||||||
"jshint-stylish": "2.x.x", |
|
||||||
"tap-spec": "4.x.x", |
|
||||||
"tape": "4.x.x", |
|
||||||
"testling": "1.x.x" |
|
||||||
}, |
|
||||||
"homepage": "https://github.com/const-io/pinf-float64#readme", |
|
||||||
"keywords": [ |
|
||||||
"const.io", |
|
||||||
"const", |
|
||||||
"constant", |
|
||||||
"const-io", |
|
||||||
"compute.io", |
|
||||||
"compute-io", |
|
||||||
"computation", |
|
||||||
"compute", |
|
||||||
"mathematics", |
|
||||||
"math", |
|
||||||
"pinf", |
|
||||||
"positive", |
|
||||||
"infinity" |
|
||||||
], |
|
||||||
"license": "MIT", |
|
||||||
"main": "./lib", |
|
||||||
"name": "const-pinf-float64", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git://github.com/const-io/pinf-float64.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"coverage": "istanbul cover --dir ./reports/codecov/coverage --report lcovonly tape -- \"./test/*.js\" && cat ./reports/codecov/coverage/lcov.info | codecov && rm -rf ./reports/codecov", |
|
||||||
"test": "if [ \"${TRAVIS}\" ]; then npm run test-ci; else npm run test-local; fi", |
|
||||||
"test-browsers": "browserify ./test/*.js | testling | tap-spec", |
|
||||||
"test-ci": "npm run test-local && xvfb-run npm run test-browsers", |
|
||||||
"test-cov": "istanbul cover --dir ./reports/coverage --report lcov tape -- \"./test/*.js\"", |
|
||||||
"test-local": "tape \"./test/*.js\" | tap-spec" |
|
||||||
}, |
|
||||||
"testling": { |
|
||||||
"files": [ |
|
||||||
"test/*.js" |
|
||||||
], |
|
||||||
"browsers": [ |
|
||||||
"iexplore/6.0..latest", |
|
||||||
"firefox/3.0..latest", |
|
||||||
"firefox/nightly", |
|
||||||
"chrome/4.0..latest", |
|
||||||
"chrome/canary", |
|
||||||
"opera/10.0..latest", |
|
||||||
"opera/next", |
|
||||||
"safari/4.0..latest", |
|
||||||
"ipad/6.0..latest", |
|
||||||
"iphone/6.0..latest", |
|
||||||
"android-browser/4.2..latest" |
|
||||||
] |
|
||||||
}, |
|
||||||
"version": "1.0.0" |
|
||||||
} |
|
@ -1,7 +0,0 @@ |
|||||||
# Deprecated Package |
|
||||||
|
|
||||||
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name. |
|
||||||
|
|
||||||
It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in. |
|
||||||
|
|
||||||
Please contact support@npmjs.com if you have questions about this package. |
|
@ -1,45 +0,0 @@ |
|||||||
{ |
|
||||||
"_from": "crypto", |
|
||||||
"_id": "crypto@1.0.1", |
|
||||||
"_inBundle": false, |
|
||||||
"_integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==", |
|
||||||
"_location": "/crypto", |
|
||||||
"_phantomChildren": {}, |
|
||||||
"_requested": { |
|
||||||
"type": "tag", |
|
||||||
"registry": true, |
|
||||||
"raw": "crypto", |
|
||||||
"name": "crypto", |
|
||||||
"escapedName": "crypto", |
|
||||||
"rawSpec": "", |
|
||||||
"saveSpec": null, |
|
||||||
"fetchSpec": "latest" |
|
||||||
}, |
|
||||||
"_requiredBy": [ |
|
||||||
"#USER", |
|
||||||
"/" |
|
||||||
], |
|
||||||
"_resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", |
|
||||||
"_shasum": "2af1b7cad8175d24c8a1b0778255794a21803037", |
|
||||||
"_spec": "crypto", |
|
||||||
"_where": "/home/sigonasr2/divar/server", |
|
||||||
"author": "", |
|
||||||
"bugs": { |
|
||||||
"url": "https://github.com/npm/deprecate-holder/issues" |
|
||||||
}, |
|
||||||
"bundleDependencies": false, |
|
||||||
"deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.", |
|
||||||
"description": "This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.", |
|
||||||
"homepage": "https://github.com/npm/deprecate-holder#readme", |
|
||||||
"license": "ISC", |
|
||||||
"main": "index.js", |
|
||||||
"name": "crypto", |
|
||||||
"repository": { |
|
||||||
"type": "git", |
|
||||||
"url": "git+https://github.com/npm/deprecate-holder.git" |
|
||||||
}, |
|
||||||
"scripts": { |
|
||||||
"test": "echo \"Error: no test specified\" && exit 1" |
|
||||||
}, |
|
||||||
"version": "1.0.1" |
|
||||||
} |
|
@ -1,16 +0,0 @@ |
|||||||
lib-cov |
|
||||||
*.seed |
|
||||||
*.log |
|
||||||
*.csv |
|
||||||
*.dat |
|
||||||
*.out |
|
||||||
*.pid |
|
||||||
*.gz |
|
||||||
|
|
||||||
pids |
|
||||||
logs |
|
||||||
results |
|
||||||
|
|
||||||
npm-debug.log |
|
||||||
node_modules/* |
|
||||||
test/* |
|
@ -1,6 +0,0 @@ |
|||||||
language: node_js |
|
||||||
node_js: |
|
||||||
- "0.8" |
|
||||||
- "0.10" |
|
||||||
before_install: |
|
||||||
- npm install -g npm@~1.4.6 |
|