Compare commits

...

34 Commits

Author SHA1 Message Date
01cafc98c3 version bump 1.2.3 2022-08-20 17:30:07 -04:00
3bd21324db ESM build 2022-08-13 00:29:46 -04:00
02389a3823 replace git.io links 2022-04-26 18:35:36 -04:00
6a752a8568 version bump 1.2.2 2022-04-04 18:53:34 -04:00
Garrett Luu
a1bcb01e8e crc32-cli 2022-04-04 14:53:03 -07:00
d64513c952 version bump 1.2.1 2022-01-25 00:48:10 -05:00
101arrowz
d2e236fe5e Slice-by-16 for buf and bstr (fixes #17) 2022-01-24 13:00:36 -08:00
9f97346755 CRC32C 2022-01-24 03:14:46 -05:00
Ryan Ghods
49af36393a
Update package.json 2022-01-20 20:21:19 -08:00
Ryan Ghods
3093cbddca
package.json: use file extensions
for esmodules compatibility
2022-01-20 14:50:25 -08:00
0d509b2f91 added test artifacts 2019-10-08 02:43:14 -04:00
16bcde00df License text 2019-10-08 02:07:56 -04:00
58bae10e50 node 4.x Buffer.from fix 2018-07-07 21:02:33 -04:00
238dc0e647 flow switch to module.exports 2018-04-21 10:09:47 -04:00
13f8e4f8f4 increased test timeout for node 8.x / 9.x
see https://github.com/nodejs/node/issues/18218
2018-01-17 19:35:19 -05:00
02caecf54f version bump 1.2.0: infrastructure 2018-01-17 16:27:59 -05:00
2253617eae version bump 1.1.1: typescript definitions 2017-09-14 01:28:51 -04:00
43cef94e0a version bump 1.1.0: pin dependencies 2017-07-28 03:25:16 -04:00
7fe46c8fa9 flow and travis fixes 2017-06-12 16:12:23 -04:00
63ef494ee7 update paths for gh-pages [ci skip] 2017-04-27 17:39:25 -04:00
029cc99249 version bump 1.0.2: demos and CLI 2017-04-27 17:33:14 -04:00
6927488edc test node 7 in travis 2017-03-29 02:52:49 -04:00
5a7e4db973 version bump 1.0.1: bstr performance
The buffer fallback is incredibly slow
2016-10-12 15:46:18 -04:00
e233fbd509 pared down IE7/IE8 tests [ci skip] 2016-10-10 19:45:29 -04:00
1045f4f8e8 version bump 1.0.0: rolling checksums
- browser tests work in IE6+
- miscellaneous adjustments to tooling
2016-10-08 15:26:03 -04:00
e1c9c5e5cd version bump 0.4.1
- normalized crc iteration logic
- added browser demo
- added command line tool crc32
- fixed unicode baseline script (node 6 changed default array printing)
- fixed performance tests (benchmark module changed behavior)
- updated travis versions for test
- miscellaneous adjustments to tooling
2016-06-16 17:16:58 -04:00
79a265b662 version bump 0.4.0
- added missing bitshift (fixes #5)
- brute-force unicode tests
2016-01-12 22:30:35 -05:00
74dda6db02 updating travis ci node versions 2015-11-20 17:30:17 -05:00
Milk Lee
b1d8309717 AMD support 2015-05-06 15:27:03 -07:00
6cdecfeb22 version bump 0.3.0: cleanup and flow 2015-05-06 14:47:18 -07:00
5cc2f712b1 version bump 0.2.2: streamlined node module 2014-07-05 22:17:30 -04:00
370bee1ad6 Merge pull request #2 from Mithgol/patch-1
use SVG to display coverage status
2014-06-21 00:16:09 -04:00
Mithgol
20b243fbe2 use SVG to display coverage status 2014-06-21 07:55:56 +04:00
a4753c597f add perf test to travis 2014-06-20 23:03:53 -04:00
187 changed files with 6699168 additions and 667 deletions

18
.eslintrc Normal file

@ -0,0 +1,18 @@
{
"env": { "shared-node-browser":true },
"globals": {},
"parserOptions": {
"ecmaVersion": 3,
},
"plugins": [ "html", "json" ],
"extends": "eslint:recommended",
"rules": {
"comma-style": [ 2, "last" ],
"comma-dangle": [ 2, "never" ],
"curly": 0,
"no-bitwise": 0,
"no-console": 0,
"no-trailing-spaces": 2,
"semi": [ 2, "always" ]
}
}

29
.flowconfig Normal file

@ -0,0 +1,29 @@
[ignore]
.*/node_modules/.*
.*/dist/.*
.*/test.js
.*/crc32.js
.*/bits/.*
.*/ctest/.*
.*/misc/.*
.*/perf/.*
.*/demo/browser.js
.*/shim.js
[include]
crc32.flow.js
.*/bin/.*.njs
.*/demo/browser.flow.js
[libs]
bits/10_types.js
misc/flow.js
misc/flowdeps.js
[options]
module.file_ext=.js
module.file_ext=.njs
module.ignore_non_literal_requires=true
suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore

92
.github/workflows/node-4+.yml vendored Normal file

@ -0,0 +1,92 @@
name: 'Tests: node.js'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
versionsAsRoot: true
type: 'majors'
preset: '>=4'
latest:
needs: [matrix]
name: 'latest majors'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
include:
- node-version: '14.'
env:
TZ: America/New_York
- node-version: '13.'
env:
TZ: Europe/London
- node-version: '12.'
env:
TZ: Asia/Seoul
- node-version: '11.'
env:
TZ: America/Los_Angeles
FMTS: misc
- node-version: '10.'
env:
TZ: Europe/Berlin
FMTS: misc
- node-version: '9.'
env:
TZ: Asia/Kolkata
FMTS: misc
- node-version: '8.'
env:
TZ: Asia/Shanghai
FMTS: misc
- node-version: '7.'
env:
TZ: America/Cancun
FMTS: misc
- node-version: '6.'
env:
TZ: Asia/Seoul
FMTS: misc
- node-version: '5.'
env:
TZ: America/Anchorage
FMTS: misc
- node-version: '4.'
env:
TZ: America/Barbados
FMTS: misc
- node-version: '4.4.7' # see GH issue #1150
env:
TZ: Asia/Tokyo
FMTS: misc
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
node-version: ${{ matrix.node-version }}
- run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64
- run: sudo chmod a+x /usr/bin/rooster
#- run: make init
#- run: 'cd test_files; make all; cd -'
- run: npm run test
#- run: 'cd packages/ssf; npm install; npm run tests-only; cd -'
node:
name: 'node 4+'
needs: [latest]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

45
.github/workflows/node-iojs.yml vendored Normal file

@ -0,0 +1,45 @@
name: 'Tests: node.js (io.js)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
type: 'majors'
preset: 'iojs'
latest:
needs: [matrix]
name: 'latest majors'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
node-version: ${{ matrix.node-version }}
skip-ls-check: true
- run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64
- run: sudo chmod a+x /usr/bin/rooster
#- run: make init
#- run: 'cd test_files; make all; cd -'
- run: npm run test
#- run: 'cd packages/ssf; npm run tests-only; cd -'
node:
name: 'io.js'
needs: [latest]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

32
.github/workflows/node-pretest.yml vendored Normal file

@ -0,0 +1,32 @@
name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
pretest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install lts/* && npm install'
with:
node-version: 'lts/*'
- run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64
- run: sudo chmod a+x /usr/bin/rooster
#- run: make init
#- run: 'cd test_files; make all; cd -'
#- run: npm run pretest
# posttest:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: ljharb/actions/node/install@main
# name: 'nvm install lts/* && npm install'
# with:
# node-version: 'lts/*'
# - run: make init
# - run: 'cd test_files; make all; cd -'
# - run: npm run posttest

88
.github/workflows/node-zero.yml vendored Normal file

@ -0,0 +1,88 @@
name: 'Tests: node.js (0.x)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
stable: ${{ steps.set-matrix.outputs.requireds }}
# unstable: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
versionsAsRoot: true
preset: '0.x'
stable:
needs: [matrix]
name: 'stable minors'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.stable) }}
include:
- node-version: '0.12.'
env:
TZ: America/Cayman
FMTS: misc
- node-version: '0.10.'
env:
TZ: Pacific/Honolulu
FMTS: misc
#- node-version: '0.8.'
# env:
# TZ: America/Mexico_City
# FMTS: misc
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
node-version: ${{ matrix.node-version }}
cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
skip-ls-check: true
- run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64
- run: sudo chmod a+x /usr/bin/rooster
#- run: make init
#- run: 'cd test_files; make all; cd -'
- run: npm run test
#- run: 'cd packages/ssf; npm run tests-only; cd -'
# unstable:
# needs: [matrix, stable]
# name: 'unstable minors'
# continue-on-error: true
# if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# node-version: ${{ fromJson(needs.matrix.outputs.unstable) }}
#
# steps:
# - uses: actions/checkout@v2
# - uses: ljharb/actions/node/install@main
# name: 'nvm install ${{ matrix.node-version }} && npm install'
# with:
# node-version: ${{ matrix.node-version }}
# cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
# skip-ls-check: true
# - run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64
# - run: sudo chmod a+x /usr/bin/rooster
# - run: make init
# - run: 'cd test_files; make all; cd -'
# - run: npm run tests-only
node:
name: 'node 0.x'
# needs: [stable, unstable]
needs: [stable]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

6
.gitignore vendored

@ -1,3 +1,7 @@
node_modules
*.tgz
test_files/*.py
test_files/*.js
test_files/baseline*
misc/coverage.html
misc/*/
ctest/sauce*

4
.jshintrc Normal file

@ -0,0 +1,4 @@
{
"bitwise": false,
"curly": false
}

10
.spelling Normal file

@ -0,0 +1,10 @@
# crc32.js (C) 2014-present SheetJS -- http://sheetjs.com
SheetJS
32-bit
CRC-32
UCS-2
UTF-8
crc32
checksum
nodejs
npm

@ -1,10 +1,18 @@
language: node_js
node_js:
- "0.11"
- "9"
- "8"
- "7"
- "6"
- "5"
- "4"
- "0.12"
- "0.10"
- "0.8"
before_install:
- "npm install -g mocha"
- "npm install -g npm@4.3.0"
- "npm install -g mocha@2.x voc"
- "npm install codepage"
- "npm install blanket"
- "npm install coveralls mocha-lcov-reporter"
after_success:

191
LICENSE

@ -1,4 +1,192 @@
Copyright (C) 2014 SheetJS
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright (C) 2014-present SheetJS LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -11,4 +199,3 @@ Copyright (C) 2014 SheetJS
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

131
Makefile

@ -1,57 +1,126 @@
LIB=crc32
REQS=
ADDONS=
AUXTARGETS=crc32c.js demo/browser.js
CMDS=bin/crc32.njs
HTMLLINT=index.html
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
DEPS=$(sort $(wildcard bits/*.js))
TARGET=$(LIB).js
FLOWTARGET=$(LIB).flow.js
FLOWTGTS=$(TARGET) $(AUXTARGETS)
CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar
$(TARGET): $(DEPS)
ESMJSTGT=crc32.mjs
ESMJSDEPS=$(shell cat misc/mjs.lst)
## Main Targets
.PHONY: all
all: $(TARGET) $(AUXTARGETS) $(ESMJSTGT) crc32c.mjs ## Build library and auxiliary scripts
$(FLOWTGTS): %.js : %.flow.js
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@
$(FLOWTARGET): $(DEPS)
cat $^ | tr -d '\15\32' > $@
$(ESMJSTGT): $(ESMJSDEPS)
cat $^ | tr -d '\15\32' > $@
cp -f $@ ctest/
bits/01_version.js: package.json
echo "CRC32.version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
.PHONY: clean
clean:
rm -f $(TARGET)
clean: clean-baseline ## Remove targets and build artifacts
rm -f $(TARGET) $(FLOWTARGET)
crc32c.flow.js: crc32.flow.js
cat $^ | sed 's/-306674912/-2097792136/g; s/CRC32\([ \/\.]\)/CRC32C\1/g' > $@
crc32c.mjs: crc32.mjs
cat $^ | sed 's/-306674912/-2097792136/g; s/CRC32\([ \/\.]\)/CRC32C\1/g' > $@
## Testing
.PHONY: test mocha
test mocha: test.js
mocha -R spec
test mocha: test.js $(TARGET) baseline ## Run test suite
./node_modules/.bin/mocha -R spec -t 60000
.PHONY: ctest
ctest:
ctest: ## Build browser test (into ctest/ subdirectory)
cat misc/*.js > ctest/fixtures.js
cp -f test.js ctest/test.js
cp -f $(TARGET) ctest/
cp -f shim.js ctest/shim.js
cp -f $(TARGET) ctest/
.PHONY: ctestserv
ctestserv: ## Start a test server on port 8000
@cd ctest && python -mSimpleHTTPServer
.PHONY: baseline
baseline: ## Build test baselines
@bash ./misc/make_baseline.sh
.PHONY: clean-baseline
clean-baseline: ## Remove test baselines
@bash ./misc/make_baseline.sh clean
## Code Checking
.PHONY: fullint
fullint: lint old-lint tslint flow mdlint ## Run all checks
.PHONY: lint
lint: $(TARGET)
jshint --show-non-errors $(TARGET)
jscs $(TARGET)
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
.PHONY: cov cov-spin
cov: misc/coverage.html
cov-spin:
make cov & bash misc/spin.sh $$!
.PHONY: old-lint
old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
@jshint --show-non-errors $(CMDS)
@jshint --show-non-errors package.json
@jshint --show-non-errors --extract=always $(HTMLLINT)
@jscs $(TARGET) $(AUXTARGETS)
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
COVFMT=$(patsubst %,cov_%,$(FMT))
.PHONY: $(COVFMT)
$(COVFMT): cov_%:
FMTS=$* make cov
.PHONY: tslint
tslint: $(TARGET) ## Run typescript checks
#@npm install dtslint typescript
#@npm run-script dtslint
dtslint types
.PHONY: flow
flow: lint ## Run flow checker
@flow check --all --show-all-errors
.PHONY: cov
cov: misc/coverage.html ## Run coverage test
misc/coverage.html: $(TARGET) test.js
mocha --require blanket -R html-cov > $@
./node_modules/.bin/mocha --require blanket -R html-cov -t 60000 > $@
.PHONY: coveralls coveralls-spin
coveralls:
mocha --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
.PHONY: coveralls
coveralls: ## Coverage Test + Send to coveralls.io
./node_modules/.bin/mocha --require blanket --reporter mocha-lcov-reporter -t 60000 | node ./node_modules/coveralls/bin/coveralls.js
coveralls-spin:
make coveralls & bash misc/spin.sh $$!
MDLINT=README.md
.PHONY: mdlint
mdlint: $(MDLINT) ## Check markdown documents
alex $^
mdspell -a -n -x -r --en-us $^
.PHONY: perf
perf:
bash perf/perf.sh
perf: ## Run Performance Tests
@bash perf/perf.sh
.PHONY: perf-all
perf-all:
bash misc/perf.sh
.PHONY: help
help:
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh
#* To show a spinner, append "-spin" to any target e.g. cov-spin
%-spin:
@make $* & bash misc/spin.sh $$!

229
README.md

@ -1,63 +1,226 @@
# crc32
Standard CRC-32 algorithm implementation in JS (for the browser and nodejs).
Emphasis on correctness and performance.
Emphasis on correctness, performance, and IE6+ support.
## Installation
In [nodejs](https://www.npmjs.org/package/crc-32):
With a node package manager like `npm`:
npm install crc-32
```bash
$ npm i --save https://cdn.sheetjs.com/crc-32-latest/crc-32-latest.tgz
```
In the browser:
When installed globally, npm installs a script `crc32` that computes the
checksum for a specified file or standard input.
<script lang="javascript" src="crc32.js"></script>
Hosted versions are available at <https://cdn.sheetjs.com/>:
The browser exposes a variable CRC32
- `crc32.js` (CommonJS): <https://cdn.sheetjs.com/crc-32-latest/package/crc32.js>
- `crc32.mjs` (ESM): <https://cdn.sheetjs.com/crc-32-latest/package/crc32.mjs>
- `crc32c.js` (CommonJS): <https://cdn.sheetjs.com/crc-32-latest/package/crc32c.js>
- `crc32c.mjs` (ESM): <https://cdn.sheetjs.com/crc-32-latest/package/crc32c.mjs>
## Integration
Using NodeJS or a bundler with `require`:
```js
var CRC32 = require("crc-32");
```
Using NodeJS or a bundler with `import`:
```js
import { bstr, buf, str } from "crc-32";
```
In the browser, the `crc32.js` script can be loaded directly:
```html
<script src="crc32.js"></script>
```
The browser script exposes a variable `CRC32`.
The script will manipulate `module.exports` if available . This is not always
desirable. To prevent the behavior, define `DO_NOT_EXPORT_CRC`.
### CRC32C (Castagnoli)
The module and CDNs also include a parallel script for CRC32C calculations.
Using NodeJS or a bundler:
```js
var CRC32C = require("crc-32/crc32c");
```
Using NodeJS or a bundler with `import`:
```js
import { bstr, buf, str } from "crc-32/crc32c";
```
In the browser, the `crc32c.js` script can be loaded directly:
```html
<script src="crc32c.js"></script>
```
The browser exposes a variable `CRC32C`.
The script will manipulate `module.exports` if available . This is not always
desirable. To prevent the behavior, define `DO_NOT_EXPORT_CRC`.
## Usage
- `CRC32.buf(byte array or buffer)` assumes the argument is a set of 8 bit
unsigned integers (e.g. nodejs `Buffer` or simple array of ints)
In all cases, the relevant function takes an argument representing data and an
optional second argument representing the starting "seed" (for rolling CRC).
- `CRC32.bstr(binary string)` interprets the argument as a binary string where
the `i`-th byte is `str.charCodeAt(i)`
**The return value is a signed 32-bit integer!**
- `CRC32.buf(byte array or buffer[, seed])` assumes the argument is a sequence
of 8-bit unsigned integers (nodejs `Buffer`, `Uint8Array` or array of bytes).
- `CRC32.bstr(binary string[, seed])` assumes the argument is a binary string
where byte `i` is the low byte of the UCS-2 char: `str.charCodeAt(i) & 0xFF`
- `CRC32.str(string[, seed])` assumes the argument is a standard JS string and
calculates the hash of the UTF-8 encoding.
For example:
```js
// var CRC32 = require('crc-32'); // uncomment this line if in node
CRC32.str("SheetJS") // -1647298270
CRC32.bstr("SheetJS") // -1647298270
CRC32.buf([ 83, 104, 101, 101, 116, 74, 83 ]) // -1647298270
crc32 = CRC32.buf([83, 104]) // -1826163454 "Sh"
crc32 = CRC32.str("eet", crc32) // 1191034598 "Sheet"
CRC32.bstr("JS", crc32) // -1647298270 "SheetJS"
[CRC32.str("\u2603"), CRC32.str("\u0003")] // [ -1743909036, 1259060791 ]
[CRC32.bstr("\u2603"), CRC32.bstr("\u0003")] // [ 1259060791, 1259060791 ]
[CRC32.buf([0x2603]), CRC32.buf([0x0003])] // [ 1259060791, 1259060791 ]
// var CRC32C = require('crc-32/crc32c'); // uncomment this line if in node
CRC32C.str("SheetJS") // -284764294
CRC32C.bstr("SheetJS") // -284764294
CRC32C.buf([ 83, 104, 101, 101, 116, 74, 83 ]) // -284764294
crc32c = CRC32C.buf([83, 104]) // -297065629 "Sh"
crc32c = CRC32C.str("eet", crc32c) // 1241364256 "Sheet"
CRC32C.bstr("JS", crc32c) // -284764294 "SheetJS"
[CRC32C.str("\u2603"), CRC32C.str("\u0003")] // [ 1253703093, 1093509285 ]
[CRC32C.bstr("\u2603"), CRC32C.bstr("\u0003")] // [ 1093509285, 1093509285 ]
[CRC32C.buf([0x2603]), CRC32C.buf([0x0003])] // [ 1093509285, 1093509285 ]
```
### Best Practices
Even though the initial seed is optional, for performance reasons it is highly
recommended to explicitly pass the default seed 0.
In NodeJS with the native Buffer implementation, it is oftentimes faster to
convert binary strings with `Buffer.from(bstr, "binary")` first:
```js
/* Frequently slower in NodeJS */
crc32 = CRC32.bstr(bstr, 0);
/* Frequently faster in NodeJS */
crc32 = CRC32.buf(Buffer.from(bstr, "binary"), 0);
```
This does not apply to browser `Buffer` shims, and thus is not implemented in
the library directly.
### Signed Integers
Unconventional for a CRC32 checksum, this library uses signed 32-bit integers.
This is for performance reasons. Standard JS operators can convert between
signed and unsigned 32-bit integers:
```js
CRC32.str("SheetJS") // -1647298270 (signed)
CRC32.str("SheetJS") >>> 0 // 2647669026 (unsigned)
(CRC32.str("SheetJS")>>>0).toString(16) // "9dd03922" (hex)
(2647669026 | 0) // -1647298270
```
- `x >>> 0` converts a number value to unsigned 32-bit integer.
- `x | 0` converts a number value to signed 32-bit integer.
- `CRC32.str(string)` interprets the argument as a standard JS string
## Testing
`make test` will run the nodejs-based test. To run the in-browser tests, run a
local server and go to the `ctest` directory. To update the browser artifacts,
run `make ctest`.
`make test` will run the nodejs-based test.
To run the in-browser tests, run a local server and go to the `ctest` directory.
`make ctestserv` will start a python `SimpleHTTPServer` server on port 8000.
To update the browser artifacts, run `make ctest`.
To generate the bits file, use the `crc32` function from python `zlib`:
```python
>>> from zlib import crc32
>>> x="foo bar baz٪☃🍣"
>>> crc32(x)
1531648243
>>> crc32(x+x)
-218791105
>>> crc32(x+x+x)
1834240887
```
The included `crc32.njs` script can process files or standard input:
```bash
$ echo "this is a test" > t.txt
$ bin/crc32.njs t.txt
1912935186
```
For comparison, the included `crc32.py` script uses python `zlib`:
```bash
$ bin/crc32.py t.txt
1912935186
```
On OSX the command `cksum` generates unsigned CRC-32 with Algorithm 3:
```bash
$ cksum -o 3 < IE8.Win7.For.Windows.VMware.zip
1891069052 4161613172
$ crc32 --unsigned ~/Downloads/IE8.Win7.For.Windows.VMware.zip
1891069052
```
## Performance
`make perf` will run algorithmic performance tests (which should justify certain
decisions in the code).
decisions in the code).
`make perf-all` compares the performance of various crc-32 algorithms that
implement the correct form (note that the SSE intrinsic is designed for the
CRC32C checksum and uses a different polynomial).
Unexpected code patterns were based on performance testing in node and browser:
- [Loop unrolling helps!](http://jsperf.com/crc32-table/2)
## In the future ...
- Specifying an arbitrary initial CRC value
- Supporting different polynomials (e.g. CRC32C)
The [`adler-32` project](https://github.com/SheetJS/js-adler32) has more performance notes
## License
Please consult the attached LICENSE file for details. All rights not explicitly
granted by the Apache 2.0 license are reserved by the Original Author.
## Badges
[![Sauce Test Status](https://saucelabs.com/browser-matrix/crc32.svg)](https://saucelabs.com/u/crc32)
[![Build Status](https://travis-ci.org/SheetJS/js-crc32.svg?branch=master)](https://travis-ci.org/SheetJS/js-crc32)
[![Coverage Status](https://coveralls.io/repos/SheetJS/js-crc32/badge.png?branch=master)](https://coveralls.io/r/SheetJS/js-crc32?branch=master)
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/ee0e89f8b1d5b861ffbf264b8ce329a6 "githalytics.com")](http://githalytics.com/SheetJS/js-crc32)
[![Coverage Status](http://img.shields.io/coveralls/SheetJS/js-crc32/master.svg)](https://coveralls.io/r/SheetJS/js-crc32?branch=master)
[![Dependencies Status](https://david-dm.org/sheetjs/js-crc32/status.svg)](https://david-dm.org/sheetjs/js-crc32)
[![NPM Downloads](https://img.shields.io/npm/dt/crc-32.svg)](https://npmjs.org/package/crc-32)
[![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/js-xlsx)](https://ghit.me/repo/sheetjs/js-xlsx)
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-crc32?pixel)](https://github.com/SheetJS/js-crc32)

105
bin/crc32.njs Executable file

@ -0,0 +1,105 @@
#!/usr/bin/env node
/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* vim: set ts=2 ft=javascript: */
/*jshint node:true */
var X/*:CRC32Module*/;
try { X = require('../'); } catch(e) { X = require('crc-32'); }
function help()/*:number*/ {
[
"usage: crc32 [options] [filename]",
"",
"Options:",
" -h, --help output usage information",
" -V, --version output the version number",
" -S, --seed=<n> use integer seed as starting value (rolling CRC)",
" -H, --hex-seed=<h> use hex seed as starting value (rolling CRC)",
" -d, --signed print result with format `%d` (default)",
" -u, --unsigned print result with format `%u`",
" -x, --hex print result with format `%0.8x`",
" -X, --HEX print result with format `%0.8X`",
" -c, --crc32c use CRC32C (Castagnoli)",
" -F, --format=<s> use specified printf format",
"",
"Set filename = '-' or pipe data into crc32 to read from stdin",
"Default output mode is signed (-d)",
""
].forEach(function(l) { console.log(l); });
return 0;
}
function version()/*:number*/ { console.log(X.version); return 0; }
var fs = require('fs');
try { require('exit-on-epipe'); } catch(e) {}
function die(msg/*:string*/, ec/*:?number*/)/*:void*/ { console.error(msg); process.exit(ec || 0); }
var args/*:Array<string>*/ = process.argv.slice(2);
var filename/*:string*/ = "";
var fmt/*:string*/ = "";
var seed = 0, r = 10;
for(var i = 0; i < args.length; ++i) {
var arg = args[i];
if(arg.charCodeAt(0) != 45) { if(filename === "") filename = arg; continue; }
var m = arg.indexOf("=") == -1 ? arg : arg.substr(0, arg.indexOf("="));
switch(m) {
case "-": filename = "-"; break;
case "--help": case "-h": process.exit(help()); break;
case "--version": case "-V": process.exit(version()); break;
case "--crc32c": case "-c": try { X = require('../crc32c'); } catch(e) { X = require('crc-32/crc32c'); } break;
case "--signed": case "-d": fmt = "%d"; break;
case "--unsigned": case "-u": fmt = "%u"; break;
case "--hex": case "-x": fmt = "%0.8x"; break;
case "--HEX": case "-X": fmt = "%0.8X"; break;
case "--format": case "-F":
try {
require("printj");
fmt = ((m!=arg) ? arg.substr(m.length+1) : args[++i])||"";
} catch(e) {
console.error("The `crc-32` module removed the `printj` dependency for formatting");
console.error("Use the `crc32-cli` module instead:");
console.error(" $ npx crc32-cli [options] [filename]");
} break;
case "--hex-seed": case "-H": r = 16;
/* falls through */
case "--seed": case "-S":
seed=parseInt((m!=arg) ? arg.substr(m.length+1) : args[++i], r)||0; break;
default: die("crc32: unrecognized option `" + arg + "'", 22);
}
}
if(!process.stdin.isTTY) filename = filename || "-";
if(filename.length===0) die("crc32: must specify a filename ('-' for stdin)",1);
var crc32 = seed;
// $FlowIgnore -- Writable is callable but type sig disagrees
var writable = require('stream').Writable();
writable._write = function(chunk, e, cb) { crc32 = X.buf(chunk, crc32); cb(); };
writable._writev = function(chunks, cb) {
chunks.forEach(function(c) { crc32 = X.buf(c.chunk, crc32);});
cb();
};
writable.on('finish', function() {
if(fmt === "") console.log(crc32);
else try { console.log(require("printj").sprintf(fmt, crc32)); } catch(e) {
switch(fmt) {
case "%d": console.log(crc32); break;
case "%u": console.log(crc32 >>> 0); break;
case "%0.8x": console.log((crc32 >>> 0).toString(16).padStart(8, "0").toLowerCase()); break;
case "%0.8X": console.log((crc32 >>> 0).toString(16).padStart(8, "0").toUpperCase()); break;
}
}
});
if(filename === "-") process.stdin.pipe(writable);
else if(fs.existsSync(filename)) fs.createReadStream(filename).pipe(writable);
else die("crc32: " + filename + ": No such file or directory", 2);

15
bin/crc32.py Executable file

@ -0,0 +1,15 @@
#!/usr/bin/env python
# crc32.py -- calculate crc32 checksum of data
# Copyright (C) 2016-present SheetJS
from zlib import crc32
from sys import argv, stdin
args=argv[1:]
payload=""
if len(args) == 0 or args[0] == "-":
payload = stdin.read()
else:
payload = open(args[0],"rb").read()
# NOTE: python 2 returns a signed value; python3 is unsigned
print crc32(payload)

@ -1,4 +1,27 @@
/* crc32.js (C) 2014 SheetJS -- http://sheetjs.com */
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
var CRC32 = {};
(function(CRC32) {
/*exported CRC32 */
/*:: declare var DO_NOT_EXPORT_CRC:?boolean; */
/*:: declare function define(cb:()=>any):void; */
var CRC32/*:CRC32Module*/;
(function (factory/*:(a:any)=>void*/)/*:void*/ {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
define(function () {
var module/*:CRC32Module*/ = /*::(*/{}/*:: :any)*/;
factory(module);
return module;
});
} else {
factory(CRC32 = /*::(*/{}/*:: :any)*/);
}
} else {
factory(CRC32 = /*::(*/{}/*:: :any)*/);
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32/*:CRC32Module*/) {

@ -1 +1 @@
CRC32.version = '0.2.1';
CRC32.version = '1.2.3';

5
bits/10_types.js Normal file

@ -0,0 +1,5 @@
/*::
type CRC32Type = number;
type ABuf = Array<number> | Buffer | Uint8Array;
type CRC32TableType = Array<number> | Int32Array;
*/

@ -1,6 +1,6 @@
/* see perf/crc32table.js */
function signed_crc_table() {
var c, table = new Array(256);
/*global Int32Array */
function signed_crc_table()/*:CRC32TableType*/ {
var c = 0, table/*:Array<number>*/ = new Array(256);
for(var n =0; n != 256; ++n){
c = n;
@ -18,4 +18,20 @@ function signed_crc_table() {
return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;
}
var table = signed_crc_table();
var T0 = signed_crc_table();
function slice_by_16_tables(T) {
var c = 0, v = 0, n = 0, table/*:Array<number>*/ = typeof Int32Array !== 'undefined' ? new Int32Array(4096) : new Array(4096) ;
for(n = 0; n != 256; ++n) table[n] = T[n];
for(n = 0; n != 256; ++n) {
v = T[n];
for(c = 256 + n; c < 4096; c += 256) v = table[c] = (v >>> 8) ^ T[v & 0xFF];
}
var out = [];
for(n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== 'undefined' ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
return out;
}
var TT = slice_by_16_tables(T0);
var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14];

@ -1,63 +1,44 @@
/* charCodeAt is the best approach for binary strings */
var use_buffer = typeof Buffer !== 'undefined';
function crc32_bstr(bstr) {
if(bstr.length > 32768) if(use_buffer) return crc32_buf_8(Buffer(bstr));
var crc = -1, L = bstr.length - 1;
for(var i = 0; i < L;) {
crc = table[(crc ^ bstr.charCodeAt(i++)) & 0xFF] ^ (crc >>> 8);
crc = table[(crc ^ bstr.charCodeAt(i++)) & 0xFF] ^ (crc >>> 8);
}
if(i === L) crc = (crc >>> 8) ^ table[(crc ^ bstr.charCodeAt(i)) & 0xFF];
return crc ^ -1;
function crc32_bstr(bstr/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = bstr.length; i < L;) C = (C>>>8) ^ T0[(C^bstr.charCodeAt(i++))&0xFF];
return ~C;
}
function crc32_buf(buf) {
if(buf.length > 10000) return crc32_buf_8(buf);
for(var crc = -1, i = 0, L=buf.length-3; i < L;) {
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
}
while(i < L+3) crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
return crc ^ -1;
function crc32_buf(B/*:ABuf*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1, L = B.length - 15, i = 0;
for(; i < L;) C =
Tf[B[i++] ^ (C & 255)] ^
Te[B[i++] ^ ((C >> 8) & 255)] ^
Td[B[i++] ^ ((C >> 16) & 255)] ^
Tc[B[i++] ^ (C >>> 24)] ^
Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^
T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^
T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];
L += 15;
while(i < L) C = (C>>>8) ^ T0[(C^B[i++])&0xFF];
return ~C;
}
function crc32_buf_8(buf) {
for(var crc = -1, i = 0, L=buf.length-7; i < L;) {
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
}
while(i < L+7) crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
return crc ^ -1;
}
/* much much faster to intertwine utf8 and crc */
function crc32_str(str) {
for(var crc = -1, i = 0, L=str.length, c, d; i < L;) {
function crc32_str(str/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = str.length, c = 0, d = 0; i < L;) {
c = str.charCodeAt(i++);
if(c < 0x80) {
crc = (crc >>> 8) ^ table[(crc ^ c) & 0xFF];
C = (C>>>8) ^ T0[(C^c)&0xFF];
} else if(c < 0x800) {
crc = (crc >>> 8) ^ table[(crc ^ (192|((c>>6)&31))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(c&63))) & 0xFF];
C = (C>>>8) ^ T0[(C ^ (192|((c>>6)&31)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
} else if(c >= 0xD800 && c < 0xE000) {
c = (c&1023)+64; d = str.charCodeAt(i++) & 1023;
crc = (crc >>> 8) ^ table[(crc ^ (240|((c>>8)&7))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((c>>2)&63))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((d>>6)&15)|(c&3))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(d&63))) & 0xFF];
c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
C = (C>>>8) ^ T0[(C ^ (240|((c>>8)&7)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>2)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(d&63)))&0xFF];
} else {
crc = (crc >>> 8) ^ table[(crc ^ (224|((c>>12)&15))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((c>>6)&63))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(c&63))) & 0xFF];
C = (C>>>8) ^ T0[(C ^ (224|((c>>12)&15)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>6)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
}
}
return crc ^ -1;
return ~C;
}

@ -1,4 +1,7 @@
CRC32.table = table;
CRC32.table = T0;
// $FlowIgnore
CRC32.bstr = crc32_bstr;
// $FlowIgnore
CRC32.buf = crc32_buf;
// $FlowIgnore
CRC32.str = crc32_str;

@ -1 +1 @@
})(typeof exports !== "undefined" && typeof DO_NOT_EXPORT_CRC === 'undefined' ? exports : CRC32);
}));

122
crc32.flow.js Normal file

@ -0,0 +1,122 @@
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported CRC32 */
/*:: declare var DO_NOT_EXPORT_CRC:?boolean; */
/*:: declare function define(cb:()=>any):void; */
var CRC32/*:CRC32Module*/;
(function (factory/*:(a:any)=>void*/)/*:void*/ {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
define(function () {
var module/*:CRC32Module*/ = /*::(*/{}/*:: :any)*/;
factory(module);
return module;
});
} else {
factory(CRC32 = /*::(*/{}/*:: :any)*/);
}
} else {
factory(CRC32 = /*::(*/{}/*:: :any)*/);
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32/*:CRC32Module*/) {
CRC32.version = '1.2.3';
/*::
type CRC32Type = number;
type ABuf = Array<number> | Buffer | Uint8Array;
type CRC32TableType = Array<number> | Int32Array;
*/
/*global Int32Array */
function signed_crc_table()/*:CRC32TableType*/ {
var c = 0, table/*:Array<number>*/ = new Array(256);
for(var n =0; n != 256; ++n){
c = n;
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
table[n] = c;
}
return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;
}
var T0 = signed_crc_table();
function slice_by_16_tables(T) {
var c = 0, v = 0, n = 0, table/*:Array<number>*/ = typeof Int32Array !== 'undefined' ? new Int32Array(4096) : new Array(4096) ;
for(n = 0; n != 256; ++n) table[n] = T[n];
for(n = 0; n != 256; ++n) {
v = T[n];
for(c = 256 + n; c < 4096; c += 256) v = table[c] = (v >>> 8) ^ T[v & 0xFF];
}
var out = [];
for(n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== 'undefined' ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
return out;
}
var TT = slice_by_16_tables(T0);
var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14];
function crc32_bstr(bstr/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = bstr.length; i < L;) C = (C>>>8) ^ T0[(C^bstr.charCodeAt(i++))&0xFF];
return ~C;
}
function crc32_buf(B/*:ABuf*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1, L = B.length - 15, i = 0;
for(; i < L;) C =
Tf[B[i++] ^ (C & 255)] ^
Te[B[i++] ^ ((C >> 8) & 255)] ^
Td[B[i++] ^ ((C >> 16) & 255)] ^
Tc[B[i++] ^ (C >>> 24)] ^
Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^
T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^
T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];
L += 15;
while(i < L) C = (C>>>8) ^ T0[(C^B[i++])&0xFF];
return ~C;
}
function crc32_str(str/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = str.length, c = 0, d = 0; i < L;) {
c = str.charCodeAt(i++);
if(c < 0x80) {
C = (C>>>8) ^ T0[(C^c)&0xFF];
} else if(c < 0x800) {
C = (C>>>8) ^ T0[(C ^ (192|((c>>6)&31)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
} else if(c >= 0xD800 && c < 0xE000) {
c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
C = (C>>>8) ^ T0[(C ^ (240|((c>>8)&7)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>2)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(d&63)))&0xFF];
} else {
C = (C>>>8) ^ T0[(C ^ (224|((c>>12)&15)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>6)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
}
}
return ~C;
}
CRC32.table = T0;
// $FlowIgnore
CRC32.bstr = crc32_bstr;
// $FlowIgnore
CRC32.buf = crc32_buf;
// $FlowIgnore
CRC32.str = crc32_str;
}));

139
crc32.js

@ -1,11 +1,32 @@
/* crc32.js (C) 2014 SheetJS -- http://sheetjs.com */
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
var CRC32 = {};
(function(CRC32) {
CRC32.version = '0.2.1';
/* see perf/crc32table.js */
/*exported CRC32 */
var CRC32;
(function (factory) {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
define(function () {
var module = {};
factory(module);
return module;
});
} else {
factory(CRC32 = {});
}
} else {
factory(CRC32 = {});
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32) {
CRC32.version = '1.2.3';
/*global Int32Array */
function signed_crc_table() {
var c, table = new Array(256);
var c = 0, table = new Array(256);
for(var n =0; n != 256; ++n){
c = n;
@ -23,72 +44,72 @@ function signed_crc_table() {
return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;
}
var table = signed_crc_table();
/* charCodeAt is the best approach for binary strings */
var use_buffer = typeof Buffer !== 'undefined';
function crc32_bstr(bstr) {
if(bstr.length > 32768) if(use_buffer) return crc32_buf_8(Buffer(bstr));
var crc = -1, L = bstr.length - 1;
for(var i = 0; i < L;) {
crc = table[(crc ^ bstr.charCodeAt(i++)) & 0xFF] ^ (crc >>> 8);
crc = table[(crc ^ bstr.charCodeAt(i++)) & 0xFF] ^ (crc >>> 8);
var T0 = signed_crc_table();
function slice_by_16_tables(T) {
var c = 0, v = 0, n = 0, table = typeof Int32Array !== 'undefined' ? new Int32Array(4096) : new Array(4096) ;
for(n = 0; n != 256; ++n) table[n] = T[n];
for(n = 0; n != 256; ++n) {
v = T[n];
for(c = 256 + n; c < 4096; c += 256) v = table[c] = (v >>> 8) ^ T[v & 0xFF];
}
if(i === L) crc = (crc >>> 8) ^ table[(crc ^ bstr.charCodeAt(i)) & 0xFF];
return crc ^ -1;
var out = [];
for(n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== 'undefined' ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
return out;
}
var TT = slice_by_16_tables(T0);
var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14];
function crc32_bstr(bstr, seed) {
var C = seed ^ -1;
for(var i = 0, L = bstr.length; i < L;) C = (C>>>8) ^ T0[(C^bstr.charCodeAt(i++))&0xFF];
return ~C;
}
function crc32_buf(buf) {
if(buf.length > 10000) return crc32_buf_8(buf);
for(var crc = -1, i = 0, L=buf.length-3; i < L;) {
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
}
while(i < L+3) crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
return crc ^ -1;
function crc32_buf(B, seed) {
var C = seed ^ -1, L = B.length - 15, i = 0;
for(; i < L;) C =
Tf[B[i++] ^ (C & 255)] ^
Te[B[i++] ^ ((C >> 8) & 255)] ^
Td[B[i++] ^ ((C >> 16) & 255)] ^
Tc[B[i++] ^ (C >>> 24)] ^
Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^
T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^
T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];
L += 15;
while(i < L) C = (C>>>8) ^ T0[(C^B[i++])&0xFF];
return ~C;
}
function crc32_buf_8(buf) {
for(var crc = -1, i = 0, L=buf.length-7; i < L;) {
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
}
while(i < L+7) crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
return crc ^ -1;
}
/* much much faster to intertwine utf8 and crc */
function crc32_str(str) {
for(var crc = -1, i = 0, L=str.length, c, d; i < L;) {
function crc32_str(str, seed) {
var C = seed ^ -1;
for(var i = 0, L = str.length, c = 0, d = 0; i < L;) {
c = str.charCodeAt(i++);
if(c < 0x80) {
crc = (crc >>> 8) ^ table[(crc ^ c) & 0xFF];
C = (C>>>8) ^ T0[(C^c)&0xFF];
} else if(c < 0x800) {
crc = (crc >>> 8) ^ table[(crc ^ (192|((c>>6)&31))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(c&63))) & 0xFF];
C = (C>>>8) ^ T0[(C ^ (192|((c>>6)&31)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
} else if(c >= 0xD800 && c < 0xE000) {
c = (c&1023)+64; d = str.charCodeAt(i++) & 1023;
crc = (crc >>> 8) ^ table[(crc ^ (240|((c>>8)&7))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((c>>2)&63))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((d>>6)&15)|(c&3))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(d&63))) & 0xFF];
c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
C = (C>>>8) ^ T0[(C ^ (240|((c>>8)&7)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>2)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(d&63)))&0xFF];
} else {
crc = (crc >>> 8) ^ table[(crc ^ (224|((c>>12)&15))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((c>>6)&63))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(c&63))) & 0xFF];
C = (C>>>8) ^ T0[(C ^ (224|((c>>12)&15)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>6)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
}
}
return crc ^ -1;
return ~C;
}
CRC32.table = table;
CRC32.table = T0;
// $FlowIgnore
CRC32.bstr = crc32_bstr;
// $FlowIgnore
CRC32.buf = crc32_buf;
// $FlowIgnore
CRC32.str = crc32_str;
})(typeof exports !== "undefined" && typeof DO_NOT_EXPORT_CRC === 'undefined' ? exports : CRC32);
}));

95
crc32.mjs Normal file

@ -0,0 +1,95 @@
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
var CRC32 = {};
CRC32.version = '1.2.3';
/*::
type CRC32Type = number;
type ABuf = Array<number> | Buffer | Uint8Array;
type CRC32TableType = Array<number> | Int32Array;
*/
/*global Int32Array */
function signed_crc_table()/*:CRC32TableType*/ {
var c = 0, table/*:Array<number>*/ = new Array(256);
for(var n =0; n != 256; ++n){
c = n;
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
table[n] = c;
}
return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;
}
var T0 = signed_crc_table();
function slice_by_16_tables(T) {
var c = 0, v = 0, n = 0, table/*:Array<number>*/ = typeof Int32Array !== 'undefined' ? new Int32Array(4096) : new Array(4096) ;
for(n = 0; n != 256; ++n) table[n] = T[n];
for(n = 0; n != 256; ++n) {
v = T[n];
for(c = 256 + n; c < 4096; c += 256) v = table[c] = (v >>> 8) ^ T[v & 0xFF];
}
var out = [];
for(n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== 'undefined' ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
return out;
}
var TT = slice_by_16_tables(T0);
var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14];
function crc32_bstr(bstr/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = bstr.length; i < L;) C = (C>>>8) ^ T0[(C^bstr.charCodeAt(i++))&0xFF];
return ~C;
}
function crc32_buf(B/*:ABuf*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1, L = B.length - 15, i = 0;
for(; i < L;) C =
Tf[B[i++] ^ (C & 255)] ^
Te[B[i++] ^ ((C >> 8) & 255)] ^
Td[B[i++] ^ ((C >> 16) & 255)] ^
Tc[B[i++] ^ (C >>> 24)] ^
Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^
T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^
T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];
L += 15;
while(i < L) C = (C>>>8) ^ T0[(C^B[i++])&0xFF];
return ~C;
}
function crc32_str(str/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = str.length, c = 0, d = 0; i < L;) {
c = str.charCodeAt(i++);
if(c < 0x80) {
C = (C>>>8) ^ T0[(C^c)&0xFF];
} else if(c < 0x800) {
C = (C>>>8) ^ T0[(C ^ (192|((c>>6)&31)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
} else if(c >= 0xD800 && c < 0xE000) {
c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
C = (C>>>8) ^ T0[(C ^ (240|((c>>8)&7)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>2)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(d&63)))&0xFF];
} else {
C = (C>>>8) ^ T0[(C ^ (224|((c>>12)&15)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>6)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
}
}
return ~C;
}
export const version = CRC32.version;
export const table = T0;
export const bstr = crc32_bstr;
export const buf = crc32_buf;
export const str = crc32_str;

122
crc32c.flow.js Normal file

@ -0,0 +1,122 @@
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported CRC32C */
/*:: declare var DO_NOT_EXPORT_CRC:?boolean; */
/*:: declare function define(cb:()=>any):void; */
var CRC32C/*:CRC32Module*/;
(function (factory/*:(a:any)=>void*/)/*:void*/ {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
define(function () {
var module/*:CRC32Module*/ = /*::(*/{}/*:: :any)*/;
factory(module);
return module;
});
} else {
factory(CRC32C = /*::(*/{}/*:: :any)*/);
}
} else {
factory(CRC32C = /*::(*/{}/*:: :any)*/);
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32C/*:CRC32Module*/) {
CRC32C.version = '1.2.3';
/*::
type CRC32Type = number;
type ABuf = Array<number> | Buffer | Uint8Array;
type CRC32TableType = Array<number> | Int32Array;
*/
/*global Int32Array */
function signed_crc_table()/*:CRC32TableType*/ {
var c = 0, table/*:Array<number>*/ = new Array(256);
for(var n =0; n != 256; ++n){
c = n;
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
table[n] = c;
}
return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;
}
var T0 = signed_crc_table();
function slice_by_16_tables(T) {
var c = 0, v = 0, n = 0, table/*:Array<number>*/ = typeof Int32Array !== 'undefined' ? new Int32Array(4096) : new Array(4096) ;
for(n = 0; n != 256; ++n) table[n] = T[n];
for(n = 0; n != 256; ++n) {
v = T[n];
for(c = 256 + n; c < 4096; c += 256) v = table[c] = (v >>> 8) ^ T[v & 0xFF];
}
var out = [];
for(n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== 'undefined' ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
return out;
}
var TT = slice_by_16_tables(T0);
var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14];
function crc32_bstr(bstr/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = bstr.length; i < L;) C = (C>>>8) ^ T0[(C^bstr.charCodeAt(i++))&0xFF];
return ~C;
}
function crc32_buf(B/*:ABuf*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1, L = B.length - 15, i = 0;
for(; i < L;) C =
Tf[B[i++] ^ (C & 255)] ^
Te[B[i++] ^ ((C >> 8) & 255)] ^
Td[B[i++] ^ ((C >> 16) & 255)] ^
Tc[B[i++] ^ (C >>> 24)] ^
Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^
T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^
T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];
L += 15;
while(i < L) C = (C>>>8) ^ T0[(C^B[i++])&0xFF];
return ~C;
}
function crc32_str(str/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = str.length, c = 0, d = 0; i < L;) {
c = str.charCodeAt(i++);
if(c < 0x80) {
C = (C>>>8) ^ T0[(C^c)&0xFF];
} else if(c < 0x800) {
C = (C>>>8) ^ T0[(C ^ (192|((c>>6)&31)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
} else if(c >= 0xD800 && c < 0xE000) {
c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
C = (C>>>8) ^ T0[(C ^ (240|((c>>8)&7)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>2)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(d&63)))&0xFF];
} else {
C = (C>>>8) ^ T0[(C ^ (224|((c>>12)&15)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>6)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
}
}
return ~C;
}
CRC32C.table = T0;
// $FlowIgnore
CRC32C.bstr = crc32_bstr;
// $FlowIgnore
CRC32C.buf = crc32_buf;
// $FlowIgnore
CRC32C.str = crc32_str;
}));

115
crc32c.js Normal file

@ -0,0 +1,115 @@
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported CRC32C */
var CRC32C;
(function (factory) {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
define(function () {
var module = {};
factory(module);
return module;
});
} else {
factory(CRC32C = {});
}
} else {
factory(CRC32C = {});
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32C) {
CRC32C.version = '1.2.3';
/*global Int32Array */
function signed_crc_table() {
var c = 0, table = new Array(256);
for(var n =0; n != 256; ++n){
c = n;
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
table[n] = c;
}
return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;
}
var T0 = signed_crc_table();
function slice_by_16_tables(T) {
var c = 0, v = 0, n = 0, table = typeof Int32Array !== 'undefined' ? new Int32Array(4096) : new Array(4096) ;
for(n = 0; n != 256; ++n) table[n] = T[n];
for(n = 0; n != 256; ++n) {
v = T[n];
for(c = 256 + n; c < 4096; c += 256) v = table[c] = (v >>> 8) ^ T[v & 0xFF];
}
var out = [];
for(n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== 'undefined' ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
return out;
}
var TT = slice_by_16_tables(T0);
var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14];
function crc32_bstr(bstr, seed) {
var C = seed ^ -1;
for(var i = 0, L = bstr.length; i < L;) C = (C>>>8) ^ T0[(C^bstr.charCodeAt(i++))&0xFF];
return ~C;
}
function crc32_buf(B, seed) {
var C = seed ^ -1, L = B.length - 15, i = 0;
for(; i < L;) C =
Tf[B[i++] ^ (C & 255)] ^
Te[B[i++] ^ ((C >> 8) & 255)] ^
Td[B[i++] ^ ((C >> 16) & 255)] ^
Tc[B[i++] ^ (C >>> 24)] ^
Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^
T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^
T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];
L += 15;
while(i < L) C = (C>>>8) ^ T0[(C^B[i++])&0xFF];
return ~C;
}
function crc32_str(str, seed) {
var C = seed ^ -1;
for(var i = 0, L = str.length, c = 0, d = 0; i < L;) {
c = str.charCodeAt(i++);
if(c < 0x80) {
C = (C>>>8) ^ T0[(C^c)&0xFF];
} else if(c < 0x800) {
C = (C>>>8) ^ T0[(C ^ (192|((c>>6)&31)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
} else if(c >= 0xD800 && c < 0xE000) {
c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
C = (C>>>8) ^ T0[(C ^ (240|((c>>8)&7)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>2)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(d&63)))&0xFF];
} else {
C = (C>>>8) ^ T0[(C ^ (224|((c>>12)&15)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>6)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
}
}
return ~C;
}
CRC32C.table = T0;
// $FlowIgnore
CRC32C.bstr = crc32_bstr;
// $FlowIgnore
CRC32C.buf = crc32_buf;
// $FlowIgnore
CRC32C.str = crc32_str;
}));

95
crc32c.mjs Normal file

@ -0,0 +1,95 @@
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
var CRC32C = {};
CRC32C.version = '1.2.3';
/*::
type CRC32Type = number;
type ABuf = Array<number> | Buffer | Uint8Array;
type CRC32TableType = Array<number> | Int32Array;
*/
/*global Int32Array */
function signed_crc_table()/*:CRC32TableType*/ {
var c = 0, table/*:Array<number>*/ = new Array(256);
for(var n =0; n != 256; ++n){
c = n;
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
c = ((c&1) ? (-2097792136 ^ (c >>> 1)) : (c >>> 1));
table[n] = c;
}
return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;
}
var T0 = signed_crc_table();
function slice_by_16_tables(T) {
var c = 0, v = 0, n = 0, table/*:Array<number>*/ = typeof Int32Array !== 'undefined' ? new Int32Array(4096) : new Array(4096) ;
for(n = 0; n != 256; ++n) table[n] = T[n];
for(n = 0; n != 256; ++n) {
v = T[n];
for(c = 256 + n; c < 4096; c += 256) v = table[c] = (v >>> 8) ^ T[v & 0xFF];
}
var out = [];
for(n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== 'undefined' ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
return out;
}
var TT = slice_by_16_tables(T0);
var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14];
function crc32_bstr(bstr/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = bstr.length; i < L;) C = (C>>>8) ^ T0[(C^bstr.charCodeAt(i++))&0xFF];
return ~C;
}
function crc32_buf(B/*:ABuf*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1, L = B.length - 15, i = 0;
for(; i < L;) C =
Tf[B[i++] ^ (C & 255)] ^
Te[B[i++] ^ ((C >> 8) & 255)] ^
Td[B[i++] ^ ((C >> 16) & 255)] ^
Tc[B[i++] ^ (C >>> 24)] ^
Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^
T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^
T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];
L += 15;
while(i < L) C = (C>>>8) ^ T0[(C^B[i++])&0xFF];
return ~C;
}
function crc32_str(str/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
var C = seed/*:: ? 0 : 0 */ ^ -1;
for(var i = 0, L = str.length, c = 0, d = 0; i < L;) {
c = str.charCodeAt(i++);
if(c < 0x80) {
C = (C>>>8) ^ T0[(C^c)&0xFF];
} else if(c < 0x800) {
C = (C>>>8) ^ T0[(C ^ (192|((c>>6)&31)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
} else if(c >= 0xD800 && c < 0xE000) {
c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
C = (C>>>8) ^ T0[(C ^ (240|((c>>8)&7)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>2)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(d&63)))&0xFF];
} else {
C = (C>>>8) ^ T0[(C ^ (224|((c>>12)&15)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>6)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
}
}
return ~C;
}
export const version = CRC32C.version;
export const table = T0;
export const bstr = crc32_bstr;
export const buf = crc32_buf;
export const str = crc32_str;

@ -1,11 +1,32 @@
/* crc32.js (C) 2014 SheetJS -- http://sheetjs.com */
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
var CRC32 = {};
(function(CRC32) {
CRC32.version = '0.2.1';
/* see perf/crc32table.js */
/*exported CRC32 */
var CRC32;
(function (factory) {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
define(function () {
var module = {};
factory(module);
return module;
});
} else {
factory(CRC32 = {});
}
} else {
factory(CRC32 = {});
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32) {
CRC32.version = '1.2.2';
/*global Int32Array */
function signed_crc_table() {
var c, table = new Array(256);
var c = 0, table = new Array(256);
for(var n =0; n != 256; ++n){
c = n;
@ -23,72 +44,72 @@ function signed_crc_table() {
return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;
}
var table = signed_crc_table();
/* charCodeAt is the best approach for binary strings */
var use_buffer = typeof Buffer !== 'undefined';
function crc32_bstr(bstr) {
if(bstr.length > 32768) if(use_buffer) return crc32_buf_8(Buffer(bstr));
var crc = -1, L = bstr.length - 1;
for(var i = 0; i < L;) {
crc = table[(crc ^ bstr.charCodeAt(i++)) & 0xFF] ^ (crc >>> 8);
crc = table[(crc ^ bstr.charCodeAt(i++)) & 0xFF] ^ (crc >>> 8);
var T0 = signed_crc_table();
function slice_by_16_tables(T) {
var c = 0, v = 0, n = 0, table = typeof Int32Array !== 'undefined' ? new Int32Array(4096) : new Array(4096) ;
for(n = 0; n != 256; ++n) table[n] = T[n];
for(n = 0; n != 256; ++n) {
v = T[n];
for(c = 256 + n; c < 4096; c += 256) v = table[c] = (v >>> 8) ^ T[v & 0xFF];
}
if(i === L) crc = (crc >>> 8) ^ table[(crc ^ bstr.charCodeAt(i)) & 0xFF];
return crc ^ -1;
var out = [];
for(n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== 'undefined' ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
return out;
}
var TT = slice_by_16_tables(T0);
var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14];
function crc32_bstr(bstr, seed) {
var C = seed ^ -1;
for(var i = 0, L = bstr.length; i < L;) C = (C>>>8) ^ T0[(C^bstr.charCodeAt(i++))&0xFF];
return ~C;
}
function crc32_buf(buf) {
if(buf.length > 10000) return crc32_buf_8(buf);
for(var crc = -1, i = 0, L=buf.length-3; i < L;) {
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
}
while(i < L+3) crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
return crc ^ -1;
function crc32_buf(B, seed) {
var C = seed ^ -1, L = B.length - 15, i = 0;
for(; i < L;) C =
Tf[B[i++] ^ (C & 255)] ^
Te[B[i++] ^ ((C >> 8) & 255)] ^
Td[B[i++] ^ ((C >> 16) & 255)] ^
Tc[B[i++] ^ (C >>> 24)] ^
Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^
T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^
T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];
L += 15;
while(i < L) C = (C>>>8) ^ T0[(C^B[i++])&0xFF];
return ~C;
}
function crc32_buf_8(buf) {
for(var crc = -1, i = 0, L=buf.length-7; i < L;) {
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
}
while(i < L+7) crc = (crc >>> 8) ^ table[(crc^buf[i++])&0xFF];
return crc ^ -1;
}
/* much much faster to intertwine utf8 and crc */
function crc32_str(str) {
for(var crc = -1, i = 0, L=str.length, c, d; i < L;) {
function crc32_str(str, seed) {
var C = seed ^ -1;
for(var i = 0, L = str.length, c = 0, d = 0; i < L;) {
c = str.charCodeAt(i++);
if(c < 0x80) {
crc = (crc >>> 8) ^ table[(crc ^ c) & 0xFF];
C = (C>>>8) ^ T0[(C^c)&0xFF];
} else if(c < 0x800) {
crc = (crc >>> 8) ^ table[(crc ^ (192|((c>>6)&31))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(c&63))) & 0xFF];
C = (C>>>8) ^ T0[(C ^ (192|((c>>6)&31)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
} else if(c >= 0xD800 && c < 0xE000) {
c = (c&1023)+64; d = str.charCodeAt(i++) & 1023;
crc = (crc >>> 8) ^ table[(crc ^ (240|((c>>8)&7))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((c>>2)&63))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((d>>6)&15)|(c&3))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(d&63))) & 0xFF];
c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
C = (C>>>8) ^ T0[(C ^ (240|((c>>8)&7)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>2)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(d&63)))&0xFF];
} else {
crc = (crc >>> 8) ^ table[(crc ^ (224|((c>>12)&15))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((c>>6)&63))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(c&63))) & 0xFF];
C = (C>>>8) ^ T0[(C ^ (224|((c>>12)&15)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|((c>>6)&63)))&0xFF];
C = (C>>>8) ^ T0[(C ^ (128|(c&63)))&0xFF];
}
}
return crc ^ -1;
return ~C;
}
CRC32.table = table;
CRC32.table = T0;
// $FlowIgnore
CRC32.bstr = crc32_bstr;
// $FlowIgnore
CRC32.buf = crc32_buf;
// $FlowIgnore
CRC32.str = crc32_str;
})(typeof exports !== "undefined" && typeof DO_NOT_EXPORT_CRC === 'undefined' ? exports : CRC32);
}));

@ -1,2 +1,2 @@
var assert = {};
assert.equal = function(x,y) { if(x !== y) throw x + " !== " + y; };
assert.equal = function(x,y) { if(x !== y) throw new Error(x + " !== " + y); };

@ -1,135 +1,47 @@
var o = "foo bar baz٪☃🍣";
var m = "foobar"; for(var i = 0; i != 11; ++i) m+=m;
var m1 = m + m, m2 = m1 + m1, m3 = m2 + m2, m4 = m3 + m3;
var M1 = m + "𝑹" + m, M2 = M1 + "𝐀" + M1, M3 = M2 + "𝓜" + M2, M4 = M3 + "𝙖" + M3;
var bits = [
[ "foobar", -1628037227, 1 ],
[ "foo bar baz", -228401567, 1 ],
[ "foo bar baz٪", 984445192 ],
[ "foo bar baz٪☃", 140429620],
[ "foo bar baz٪☃🍣", 1531648243],
[ m, 40270464, 1 ]
[ m, 40270464, 1 ],
[ m1, -239917269, 1],
[ m2, 2048324365, 1 ],
[ m3, -1695517393, 1 ],
[ m4, 1625284864, 1 ],
[ M1, 642113519 ],
[ M2, -1441250016 ],
[ M3, -1101021992 ],
[ M4, -1610723860 ],
[ o, 1531648243 ],
[ o+o, -218791105 ],
[ o+o+o, 1834240887 ]
];
if(typeof module !== "undefined") module.exports = bits;
/* vim: set ts=2: */
if(typeof require !== 'undefined') {
var js_crc32 = require('../');
var js_crc32_old = require('crc-32');
var buffer_crc32 = require('./buffer-crc32');
var crc32 = require('./crc32');
var node_crc = require('./node-crc');
/*::
declare class CRC32Module {
table:CRC32TableType;
bstr(s:string, seed?:CRC32Type):CRC32Type;
buf(b:ABuf, seed?:CRC32Type):CRC32Type;
str(s:string, seed?:CRC32Type):CRC32Type;
version:string;
};
*/
/*::
type _CB = {(data:Buffer):void;};
declare module 'concat-stream' {declare function exports(f:_CB):stream$Duplex;};
declare module 'exit-on-epipe' {};
function z1(bstr) { return js_crc32.bstr(bstr); }
function z2(bstr) { return buffer_crc32.signed(bstr); }
function z3(bstr) { return crc32(bstr); }
function z4(bstr) { return node_crc.crc32(bstr);}
function z5(bstr) { return js_crc32_old.bstr(bstr); }
declare module 'crc-32' { declare module.exports:CRC32Module; };
declare module '../' { declare module.exports:CRC32Module; };
function b1(buf) { return js_crc32.buf(buf); }
function b2(buf) { return buffer_crc32.signed(buf); }
function b3(buf) { return crc32(buf); }
function b4(buf) { return node_crc.crc32(buf); }
function b5(buf) { return js_crc32_old.buf(buf); }
function u1(str) { return js_crc32.str(str); }
function u2(str) { return buffer_crc32.signed(str); }
function u3(str) { return js_crc32_old.str(str); }
var ntests, len_max, do_bstr, do_buf, do_ustr;
switch(process.env.MODE) {
case "A": ntests = 100000; len_max = 256; break;
case "B": ntests = 10000; len_max = 1024; break;
case "C": ntests = 10000; len_max = 4096; break;
case "D": ntests = 1000; len_max = 16384; break;
case "E": ntests = 1000; len_max = 65536; break;
case "F": ntests = 100; len_max = 262144; break;
default: ntests = 10000; len_max = 1024; break;
}
if(process.argv === 2) do_bstr = do_buf = do_ustr = true;
else {
do_bstr = process.argv[2].indexOf("S") > -1;
do_buf = process.argv[2].indexOf("B") > -1;
do_ustr = process.argv[2].indexOf("U") > -1;
if(!do_bstr && !do_buf && !do_ustr) do_bstr = do_buf = do_ustr = true;
}
var btest = !!do_bstr || !!do_buf, utest = !!do_ustr;
var bstr_tests = [];
var ustr_tests = [];
var len_min = 1;
var corpus = new Array(0x0800);
for(var k = 0; k < 0x0800; ++k) corpus[k] = String.fromCharCode(k)
len_max --;
k = (Math.random()*0x800)|0;
for(var i = 0; i < ntests; ++i) {
var l = (Math.random() * (len_max - len_min))|0 + len_min;
var s = new Array(l), t = new Array(l);
if(btest) for(var j = 0; j < l; ++j) s[j] = corpus[(i+j+k)&127];
if(utest) for(var j = 0; j < l; ++j) t[j] = corpus[(i+j+k)&0x7FF];
var ss = s.join("");
bstr_tests[i] = [ss, new Buffer(ss)];
ustr_tests[i] = t.join("");
}
var assert = require('assert');
function fix(str) { return parseInt(str, 16)|0; }
if(btest) for(var j = 0; j != ntests; ++j) {
if(do_bstr && do_buf) assert.equal(z1(bstr_tests[j][0]), b1(bstr_tests[j][1]));
if(do_bstr) {
assert.equal(z1(bstr_tests[j][0]), z2(bstr_tests[j][0]));
assert.equal(z1(bstr_tests[j][0]), fix(z3(bstr_tests[j][0])));
assert.equal(z1(bstr_tests[j][0]), fix(z4(bstr_tests[j][0])));
assert.equal(z1(bstr_tests[j][0]), z5(bstr_tests[j][0]));
}
if(do_buf) {
assert.equal(b1(bstr_tests[j][1]), b2(bstr_tests[j][1]));
assert.equal(b1(bstr_tests[j][1]), fix(b3(bstr_tests[j][1])));
assert.equal(b1(bstr_tests[j][1]), fix(b4(bstr_tests[j][1])));
assert.equal(b1(bstr_tests[j][1]), b5(bstr_tests[j][1]));
}
}
if(utest) for(var j = 0; j != ntests; ++j) {
assert.equal(u1(ustr_tests[j]), u2(ustr_tests[j]));
assert.equal(u1(ustr_tests[j]), u3(ustr_tests[j]));
}
var BM = require('../perf/bm');
if(do_bstr) {
var suite = new BM('binary string (' + len_max + ')');
suite.add('js-crc32', function() { for(var j = 0; j != ntests; ++j) z1(bstr_tests[j][0]); });
suite.add('js-crc32-old', function() { for(var j = 0; j != ntests; ++j) z5(bstr_tests[j][0]); });
suite.add('buffer-crc32', function() { for(var j = 0; j != ntests; ++j) z2(bstr_tests[j][0]); });
if(len_max < 4096) {
suite.add('crc32', function() { for(var j = 0; j != ntests; ++j) z3(bstr_tests[j][0]); });
suite.add('node_crc', function() { for(var j = 0; j != ntests; ++j) z4(bstr_tests[j][0]); });
}
suite.run();
}
if(do_buf) {
suite = new BM('buffer (' + len_max + ')');
suite.add('js-crc32', function() { for(var j = 0; j != ntests; ++j) b1(bstr_tests[j][1]); });
suite.add('js-crc32-old', function() { for(var j = 0; j != ntests; ++j) b5(bstr_tests[j][1]); });
suite.add('buffer-crc32', function() { for(var j = 0; j != ntests; ++j) b2(bstr_tests[j][1]); });
if(len_max < 1024) {
suite.add('crc32', function() { for(var j = 0; j != ntests; ++j) b3(bstr_tests[j][1]); });
suite.add('node_crc', function() { for(var j = 0; j != ntests; ++j) b4(bstr_tests[j][1]); });
}
suite.run();
}
if(do_ustr) {
var suite = new BM('unicode string (' + len_max + ')');
suite.add('js-crc32', function() { for(var j = 0; j != ntests; ++j) u1(ustr_tests[j]); });
suite.add('js-crc32-old', function() { for(var j = 0; j != ntests; ++j) u3(ustr_tests[j]); });
suite.add('buffer-crc32', function() { for(var j = 0; j != ntests; ++j) u2(ustr_tests[j]); });
suite.run();
}
}
declare module 'printj' {
declare function sprintf(fmt:string, ...args:any):string;
};
*/
crc32table = [
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,

@ -8,6 +8,7 @@
</head>
<body>
<div id="mocha"></div>
<script src="shim.js"></script>
<script src="crc32.js"></script>
<script src="fakeassert.js"></script>
<script src="mocha.js"></script>

@ -136,6 +136,41 @@ body {
overflow: auto;
}
#mocha .test .html-error {
overflow: auto;
color: black;
line-height: 1.5;
display: block;
float: left;
clear: left;
font: 12px/1.5 monaco, monospace;
margin: 5px;
padding: 15px;
border: 1px solid #eee;
max-width: 85%; /*(1)*/
max-width: calc(100% - 42px); /*(2)*/
max-height: 300px;
word-wrap: break-word;
border-bottom-color: #ddd;
-webkit-border-radius: 3px;
-webkit-box-shadow: 0 1px 3px #eee;
-moz-border-radius: 3px;
-moz-box-shadow: 0 1px 3px #eee;
border-radius: 3px;
}
#mocha .test .html-error pre.error {
border: none;
-webkit-border-radius: none;
-webkit-box-shadow: none;
-moz-border-radius: none;
-moz-box-shadow: none;
padding: 0;
margin: 0;
margin-top: 18px;
max-height: none;
}
/**
* (1): approximate for browsers not supporting calc
* (2): 42 = 2*15 + 2*10 + 2*1 (padding + margin + border)

237
ctest/shim.js Normal file

@ -0,0 +1,237 @@
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
if (!Object.keys) {
Object.keys = (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
],
dontEnumsLength = dontEnums.length;
return function (obj) {
if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) throw new TypeError('Object.keys called on non-object');
var result = [];
for (var prop in obj) {
if (hasOwnProperty.call(obj, prop)) result.push(prop);
}
if (hasDontEnumBug) {
for (var i=0; i < dontEnumsLength; i++) {
if (hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i]);
}
}
return result;
};
})();
}
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp */)
{
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var res = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in t)
{
var val = t[i]; // in case fun mutates this
if (fun.call(thisp, val, i, t))
res.push(val);
}
}
return res;
};
}
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, '');
};
}
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
if (!Array.prototype.forEach)
{
Array.prototype.forEach = function(fun /*, thisArg */)
{
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++)
{
if (i in t)
fun.call(thisArg, t[i], i, t);
}
};
}
// Production steps of ECMA-262, Edition 5, 15.4.4.19
// Reference: http://es5.github.com/#x15.4.4.19
if (!Array.prototype.map) {
Array.prototype.map = function(callback, thisArg) {
var T, A, k;
if (this == null) {
throw new TypeError(" this is null or not defined");
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== "function") {
throw new TypeError(callback + " is not a function");
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (thisArg) {
T = thisArg;
}
// 6. Let A be a new array created as if by the expression new Array(len) where Array is
// the standard built-in constructor with that name and len is the value of len.
A = new Array(len);
// 7. Let k be 0
k = 0;
// 8. Repeat, while k < len
while(k < len) {
var kValue, mappedValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[ k ];
// ii. Let mappedValue be the result of calling the Call internal method of callback
// with T as the this value and argument list containing kValue, k, and O.
mappedValue = callback.call(T, kValue, k, O);
// iii. Call the DefineOwnProperty internal method of A with arguments
// Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true},
// and false.
// In browsers that support Object.defineProperty, use the following:
// Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
// For best browser support, use the following:
A[ k ] = mappedValue;
}
// d. Increase k by 1.
k++;
}
// 9. return A
return A;
};
}
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement, fromIndex) {
if ( this === undefined || this === null ) {
throw new TypeError( '"this" is null or not defined' );
}
var length = this.length >>> 0; // Hack to convert object.length to a UInt32
fromIndex = +fromIndex || 0;
if (Math.abs(fromIndex) === Infinity) {
fromIndex = 0;
}
if (fromIndex < 0) {
fromIndex += length;
if (fromIndex < 0) {
fromIndex = 0;
}
}
for (;fromIndex < length; fromIndex++) {
if (this[fromIndex] === searchElement) {
return fromIndex;
}
}
return -1;
};
}
// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
if (! Array.isArray) {
Array.isArray = function(obj) {
return Object.prototype.toString.call(obj) === "[object Array]";
};
}
// https://github.com/ttaubert/node-arraybuffer-slice
// (c) 2013 Tim Taubert <tim@timtaubert.de>
// arraybuffer-slice may be freely distributed under the MIT license.
"use strict";
if (typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) {
ArrayBuffer.prototype.slice = function (begin, end) {
begin = (begin|0) || 0;
var num = this.byteLength;
end = end === (void 0) ? num : (end|0);
// Handle negative values.
if (begin < 0) begin += num;
if (end < 0) end += num;
if (num === 0 || begin >= num || begin >= end) {
return new ArrayBuffer(0);
}
var length = Math.min(num - begin, end - begin);
var target = new ArrayBuffer(length);
var targetArray = new Uint8Array(target);
targetArray.set(new Uint8Array(this, begin, length));
return target;
};
}

@ -5,29 +5,97 @@ if(typeof require !== 'undefined') {
describe('source',function(){it('should load',function(){X=require('./');});});
bits = require('./misc/bits.js');
crc32table = require('./misc/table.js');
fs = require("fs");
} else { X = CRC32; }
function readlines(f) { return fs.readFileSync(f, "ascii").split("\n"); }
function msieversion()
{
if(typeof window == 'undefined') return Infinity;
if(typeof window.navigator == 'undefined') return Infinity;
var ua = window.navigator.userAgent
var msie = ua.indexOf ( "MSIE " )
if(msie < 0) return Infinity;
return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )));
}
var Buffer_from = function(){};
if(typeof Buffer !== 'undefined') {
var nbfs = !Buffer.from;
if(!nbfs) try { Buffer.from("foo", "utf8"); } catch(e) { nbfs = true; }
Buffer_from = nbfs ? function(buf, enc) { return (enc) ? new Buffer(buf, enc) : new Buffer(buf); } : Buffer.from.bind(Buffer);
}
describe('crc32 table', function() {
it('should match fixed table', function() {
var badness = 0;
var overflow = 0;
for(var i = 0; i != crc32table.length; ++i) {
assert.equal(crc32table[i]|0, X.table[i]);
if(crc32table[i] !== X.table[i]) ++badness;
if(crc32table[i] !== X.table[i]) ++overflow;
}
assert.equal(badness, 128);
assert.equal(overflow, 128);
});
});
describe('crc32 bits', function() {
bits.forEach(function(i) {
var l = i[0].length;
var msg = i[0];
var msg = i[0], l = i[0].length, L = i[1]|0;
if(l > 20) msg = i[0].substr(0,5) + "...(" + l + ")..." + i[0].substr(-5);
if(l > 100 && msieversion() < 9) return;
if(l > 20000 && typeof Buffer === 'undefined') return;
it(msg, function() {
if(i[2] === 1) assert.equal(X.bstr(i[0]), i[1]|0);
if(i[2] === 1) assert.equal(X.bstr(i[0]), L);
assert.equal(X.str(i[0]), i[1]|0);
if(typeof Buffer !== 'undefined') assert.equal(X.buf(new Buffer(i[0])), i[1]|0);
if(typeof Buffer !== 'undefined') assert.equal(X.buf(Buffer_from(i[0])), L);
var len = i[0].length, step = len < 20000 ? 1 : len < 50000 ? Math.ceil(len / 20000) : Math.ceil(len / 2000);
for(var x = 0; x < len; x += step) {
if(i[0].charCodeAt(x) >= 0xD800 && i[0].charCodeAt(x) < 0xE000) continue;
if(i[2] === 1) {
var bstrcrc = X.bstr(i[0].substr(x), X.bstr(i[0].substr(0, x)));
assert.equal(bstrcrc, L);
}
var strcrc = X.str(i[0].substr(x), X.str(i[0].substr(0, x)));
assert.equal(strcrc, i[1]|0);
if(typeof Buffer !== 'undefined') {
var buf = Buffer_from(i[0]);
var bufcrc = X.buf(buf.slice(x), X.buf(buf.slice(0, x)));
assert.equal(bufcrc, L);
}
}
});
});
});
if(typeof require !== 'undefined') describe("unicode", function() {
if(!fs.existsSync("./test_files/uccat.txt")) return;
var uccat = readlines("./test_files/uccat.txt");
uccat.forEach(function(cat) {
it("Category " + cat, function() {
if(!fs.existsSync("./test_files/baseline." + cat + ".txt")) return;
var corpus = readlines("./test_files/baseline." + cat + ".txt");
var uctable = require("./test_files/uctable." + cat + ".js");
for(var ucidx = 0; ucidx < uctable.length; ++ucidx) {
var c = uctable[ucidx];
/* since the baselines are passed via utf8, discard invalid codes */
if(c.charCodeAt(0) >= 0xD800 && c.charCodeAt(0) < 0xE000) continue;
var cc = corpus[ucidx], dd = X.str(c);
assert.equal(dd, cc, ":" + ucidx + ":" + c + ":" + cc + ":" + dd);
if(typeof Buffer !== 'undefined') {
var ee = X.buf(Buffer_from(c, "utf8"));
assert.equal(ee, cc, ":" + ucidx + ":" + c + ":" + cc + ":" + ee);
var ff = X.bstr(String.fromCharCode.apply(null, Buffer_from(c, "utf8")));
assert.equal(ff, cc, ":" + ucidx + ":" + c + ":" + cc + ":" + ff);
}
};
});
});
});
if(typeof require !== 'undefined') describe("corpora", function() {
require("./test_files/corpus.json").forEach(function(text) {
if(!fs.existsSync(text[1])) return;
it("should match '" + text[0] + "' (" + text[2] + ")", function() {
assert.equal(text[2], X.buf(fs.readFileSync(text[1])));
});
});
});

122
demo/browser.flow.js Normal file

@ -0,0 +1,122 @@
/*jshint browser:true */
/*eslint-env browser */
/*global CRC32, console, Uint8Array */
/*:: declare var CRC32: CRC32Module; */
var X = CRC32;
function console_log(/*:: ...args:Array<any> */) { if(typeof console !== 'undefined') console.log.apply(console, [].slice.call(arguments)); }
function lpad(s/*:string*/, len/*:number*/, chr/*:?string*/)/*:string*/{
var L/*:number*/ = len - s.length, C/*:string*/ = chr || " ";
if(L <= 0) return s;
return new Array(L+1).join(C) + s;
}
function is_defined(val/*:any*/, keys/*:Array<string>*/)/*:boolean*/ {
if(typeof val === "undefined") return false;
return keys.length === 0 || is_defined(val[keys[0]], keys.slice(1));
}
/*# buffer to string; IE String.fromCharCode.apply limit, manual chunk */
/*::
type ArrayLike = any;
type Stringifier = {(d:ArrayLike):string};
*/
function make_chunk_buf_to_str(BType/*:function*/)/*:Stringifier*/ {
return function(data/*:any*/)/*:string*/ {
var o = "", l = 0, w = 10240, L = data.byteLength/w;
for(; l<L; ++l) o+=String.fromCharCode.apply(null, ((new BType(data.slice(l*w,l*w+w)))/*:any*/));
o+=String.fromCharCode.apply(null, ((new BType(data.slice(l*w)))/*:any*/));
return o;
};
}
/*# buffer to binary string */
var bstrify/*:Stringifier*/ = make_chunk_buf_to_str(typeof Uint8Array !== 'undefined' ? Uint8Array : Array);
/*# readAsBinaryString support */
var rABS/*:boolean*/ = typeof FileReader !== 'undefined' && is_defined(FileReader, ['prototype', 'readAsBinaryString']);
var userABS/*:HTMLInputElement*/ = (document.getElementsByName("userabs")[0]/*:any*/);
if(!rABS) {
userABS.disabled = true;
userABS.checked = false;
}
/*## Process Result */
/*:: declare class HTMLPreElement extends HTMLElement { innerText?:string; } */
function process_value(val/*:CRC32Type*/) {
var output = [];
output[0] = "Signed : " + val;
output[1] = "Unsigned : " + (val>>>0);
output[2] = "Hex value : " + lpad((val>>>0).toString(16),8,'0');
var out/*:HTMLPreElement*/ = (document.getElementById('out')/*:any*/);
var o = output.join("\n");
if(typeof out.innerText == "undefined") out.textContent = o;
else out.innerText = o;
console_log("output", new Date());
}
/*## Raw Text */
var dotxt/*:HTMLInputElement*/ = (document.getElementById('dotext')/*:any*/);
dotxt.onclick = function() {
var txt/*:HTMLTextAreaElement*/=(document.getElementById('rawdata')/*:any*/);
console_log("onload", new Date());
var wb/*:CRC32Type*/ = X.str(txt.value);
process_value(wb);
};
/*# HTML5 */
var readcb = function(e/*:Event*/) {
console_log("onload", new Date(), rABS, false);
var target/*:FileReader*/ = (e.target/*:any*/);
var data = target.result;
var val/*:CRC32Type*/ = rABS ? X.bstr(/*::(*/data/*:: :any)*/) : X.str(bstrify(data));
process_value(val);
};
/*## File Input */
var handle_file = function(e/*:Event*/) {
rABS = userABS.checked;
var otarget/*:HTMLInputElement*/ = (e.target/*:any*/);
var files/*:FileList*/ = otarget.files;
var f/*:File*/ = files[0];
var reader/*:FileReader*/ = new FileReader();
reader.onload = readcb;
if(rABS) (reader/*:any*/).readAsBinaryString(f);
else reader.readAsArrayBuffer(f);
};
var xlf/*:HTMLInputElement*/ = (document.getElementById('xlf')/*:any*/);
if(xlf.addEventListener) xlf.addEventListener('change', handle_file, false);
/*## Drag and Drop File */
var handle_drop/*:EventHandler*/ = (function(e/*:DragEvent*/) {
e.stopPropagation();
e.preventDefault();
rABS = userABS.checked;
if(!e.dataTransfer) return;
var files/*:FileList*/ = e.dataTransfer.files;
var f/*:File*/ = files[0];
var reader/*:FileReader*/ = new FileReader();
reader.onload = readcb;
if(rABS) (reader/*:any*/).readAsBinaryString(f);
else reader.readAsArrayBuffer(f);
}/*:any*/);
var handle_drag/*:EventHandler*/ = (function (e/*:DragEvent*/) {
e.stopPropagation();
e.preventDefault();
if(e.dataTransfer) e.dataTransfer.dropEffect = 'copy';
}/*:any*/);
var drop/*:HTMLDivElement*/ = (document.getElementById('drop')/*:any*/);
if(drop.addEventListener) {
drop.addEventListener('dragenter', handle_drag, false);
drop.addEventListener('dragover', handle_drag, false);
drop.addEventListener('drop', handle_drop, false);
}

107
demo/browser.js Normal file

@ -0,0 +1,107 @@
/*jshint browser:true */
/*eslint-env browser */
/*global CRC32, console, Uint8Array */
var X = CRC32;
function console_log() { if(typeof console !== 'undefined') console.log.apply(console, [].slice.call(arguments)); }
function lpad(s, len, chr){
var L = len - s.length, C = chr || " ";
if(L <= 0) return s;
return new Array(L+1).join(C) + s;
}
function is_defined(val, keys) {
if(typeof val === "undefined") return false;
return keys.length === 0 || is_defined(val[keys[0]], keys.slice(1));
}
function make_chunk_buf_to_str(BType) {
return function(data) {
var o = "", l = 0, w = 10240, L = data.byteLength/w;
for(; l<L; ++l) o+=String.fromCharCode.apply(null, ((new BType(data.slice(l*w,l*w+w)))));
o+=String.fromCharCode.apply(null, ((new BType(data.slice(l*w)))));
return o;
};
}
var bstrify = make_chunk_buf_to_str(typeof Uint8Array !== 'undefined' ? Uint8Array : Array);
var rABS = typeof FileReader !== 'undefined' && is_defined(FileReader, ['prototype', 'readAsBinaryString']);
var userABS = (document.getElementsByName("userabs")[0]);
if(!rABS) {
userABS.disabled = true;
userABS.checked = false;
}
function process_value(val) {
var output = [];
output[0] = "Signed : " + val;
output[1] = "Unsigned : " + (val>>>0);
output[2] = "Hex value : " + lpad((val>>>0).toString(16),8,'0');
var out = (document.getElementById('out'));
var o = output.join("\n");
if(typeof out.innerText == "undefined") out.textContent = o;
else out.innerText = o;
console_log("output", new Date());
}
var dotxt = (document.getElementById('dotext'));
dotxt.onclick = function() {
var txt=(document.getElementById('rawdata'));
console_log("onload", new Date());
var wb = X.str(txt.value);
process_value(wb);
};
var readcb = function(e) {
console_log("onload", new Date(), rABS, false);
var target = (e.target);
var data = target.result;
var val = rABS ? X.bstr(data) : X.str(bstrify(data));
process_value(val);
};
var handle_file = function(e) {
rABS = userABS.checked;
var otarget = (e.target);
var files = otarget.files;
var f = files[0];
var reader = new FileReader();
reader.onload = readcb;
if(rABS) (reader).readAsBinaryString(f);
else reader.readAsArrayBuffer(f);
};
var xlf = (document.getElementById('xlf'));
if(xlf.addEventListener) xlf.addEventListener('change', handle_file, false);
var handle_drop = (function(e) {
e.stopPropagation();
e.preventDefault();
rABS = userABS.checked;
if(!e.dataTransfer) return;
var files = e.dataTransfer.files;
var f = files[0];
var reader = new FileReader();
reader.onload = readcb;
if(rABS) (reader).readAsBinaryString(f);
else reader.readAsArrayBuffer(f);
});
var handle_drag = (function (e) {
e.stopPropagation();
e.preventDefault();
if(e.dataTransfer) e.dataTransfer.dropEffect = 'copy';
});
var drop = (document.getElementById('drop'));
if(drop.addEventListener) {
drop.addEventListener('dragenter', handle_drag, false);
drop.addEventListener('dragover', handle_drag, false);
drop.addEventListener('drop', handle_drop, false);
}

28
demo/work.js Normal file

@ -0,0 +1,28 @@
/* js-crc32 (C) 2014-present SheetJS -- http://sheetjs.com */
/*:: declare var CRC32: CRC32Module; */
/*:: declare var self: DedicatedWorkerGlobalScope; */
importScripts('../crc32.js');
/*::self.*/postMessage({t:"ready"});
var recrc = function(f, crc, l) {
/*::self.*/postMessage({t:"iter", f:f, crc:crc, l:l, sz:f.size});
if(l >= f.size) return /*::self.*/postMessage({t:"done"});
var sz = 0x100000; if(l + sz > f.size) sz = f.size - l;
var d = f.slice(l, l + sz);
var r = new FileReader();
r.onload = function(e) {
var b = new Uint8Array(e.target.result);
var newcrc = CRC32.buf(b, crc);
/*::self.*/postMessage({t:"data", crc:newcrc, bytes:l+sz});
recrc(f, newcrc, l + sz);
};
r.readAsArrayBuffer(d);
};
onmessage = function (oEvent) {
/*::self.*/postMessage({t:"start"});
var f/*:File*/ = oEvent.data;
var seed = 0;
recrc(f, seed, 0);
};

69
demo/worker.flow.js Normal file

@ -0,0 +1,69 @@
/*jshint browser:true */
function lpad(s/*:string*/, len/*:number*/, chr/*:?string*/)/*:string*/{
var L/*:number*/ = len - s.length, C/*:string*/ = chr || " ";
if(L <= 0) return s;
return new Array(L+1).join(C) + s;
}
function is_defined(val/*:any*/, keys/*:Array<string>*/)/*:boolean*/ {
if(typeof val === "undefined") return false;
return keys.length === 0 || is_defined(val[keys[0]], keys.slice(1));
}
/*## Process Result */
/*:: declare class HTMLPreElement extends HTMLElement { innerText?:string; } */
function process_value(val/*:CRC32Type*/, progress/*:number*/) {
var output = [];
output[0] = "Progress : %" + lpad(progress.toFixed(2), 6, " ");
output[1] = "Signed : " + val;
output[2] = "Unsigned : " + (val>>>0);
output[3] = "Hex value : " + lpad((val>>>0).toString(16),8,'0');
var out/*:HTMLPreElement*/ = (document.getElementById('out')/*:any*/);
var o = output.join("\n");
if(typeof out.innerText == "undefined") out.textContent = o;
else out.innerText = o;
}
/*::
type WMessage = {
t:string;
f:File;
crc:CRC32Type;
l:number;
sz:number;
bytes:number;
};
*/
/*# Drag and Drop File */
var handle_drop/*:EventHandler*/ = (function(e/*:DragEvent*/) {
e.stopPropagation();
e.preventDefault();
if(!e.dataTransfer) return;
var files/*:FileList*/ = e.dataTransfer.files;
var f/*:File*/ = files[0];
var worker = new Worker("demo/work.js");
worker.postMessage(f);
worker.onmessage = function(M) { var m/*:WMessage*/ = (M.data/*:any*/); switch(m.t) {
case 'ready': break;
case 'start': break;
case 'data': process_value(m.crc, 100 * m.bytes / f.size); break;
case 'done': break;
} };
}/*:any*/);
var handle_drag/*:EventHandler*/ = (function (e/*:DragEvent*/) {
e.stopPropagation();
e.preventDefault();
if(e.dataTransfer) e.dataTransfer.dropEffect = 'copy';
}/*:any*/);
var drop/*:HTMLDivElement*/ = (document.getElementById('drop')/*:any*/);
if(drop.addEventListener) {
drop.addEventListener('dragenter', handle_drag, false);
drop.addEventListener('dragover', handle_drag, false);
drop.addEventListener('drop', handle_drop, false);
}

60
index.html Normal file

@ -0,0 +1,60 @@
<!DOCTYPE html>
<!-- crc32.js (C) 2014-present SheetJS http://sheetjs.com -->
<!-- vim: set ts=2: -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>JS-CRC32 Live Demo</title>
<style>
#drop{
border:2px dashed #bbb;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
padding:25px;
text-align:center;
font:20pt bold,"Vollkorn";color:#bbb
}
#rawdata{
width:100%;
}
a { text-decoration: none }
</style>
</head>
<body>
<pre>
<b><a href="http://sheetjs.com/bits">SheetJS JS-CRC32 Live Demo</a></b>
(text works back to IE6; drag and drop works back to IE10)
(<b>This demo loads the entire file at once!</b> For newer browsers, <a href="large.html">try the large file demo</a>)
<a href="https://github.com/SheetJS/js-crc32">Source Code Repo</a>
<a href="https://github.com/SheetJS/js-crc32/issues">Issues? Something look weird? Click here and report an issue</a>
<br />
<div id="drop">Drop a text file to compute the CRC-32 checksum</div>
<input type="file" name="xlfile" id="xlf" /> ... or click here to select a file
<textarea id="rawdata">... or paste text here</textarea>
<input type="button" id="dotext" value="Click here to process the text"/><br />
<b>Advanced Demo Options:</b>
Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" checked><br />
</pre>
<pre id="out"></pre>
<br />
<script type="text/javascript">/* jshint browser: true */</script>
<script src="shim.js"></script>
<script src="crc32.js"></script>
<script src="demo/browser.flow.js"></script>
<script type="text/javascript">
/*eslint-env browser */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36810333-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

49
large.html Normal file

@ -0,0 +1,49 @@
<!DOCTYPE html>
<!-- crc32.js (C) 2014-present SheetJS http://sheetjs.com -->
<!-- vim: set ts=2: -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>JS-CRC32 Live Demo</title>
<style>
#drop{
border:2px dashed #bbb;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
padding:25px;
text-align:center;
font:20pt bold,"Vollkorn";color:#bbb
}
a { text-decoration: none }
</style>
</head>
<body>
<pre>
<b><a href="http://sheetjs.com/bits">SheetJS JS-CRC32 Live Demo</a></b>
(text works back to IE6; drag and drop works back to IE10)
<a href="https://github.com/SheetJS/js-crc32">Source Code Repo</a>
<a href="https://github.com/SheetJS/js-crc32/issues">Issues? Something look weird? Click here and report an issue</a>
<br />
<div id="drop">Drop a text file to compute the CRC-32 checksum</div>
<pre id="out"></pre>
<br />
<script type="text/javascript">/* jshint browser: true */</script>
<script src="shim.js"></script>
<script src="crc32.js"></script>
<script src="demo/worker.flow.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36810333-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

3
misc/00_header.js Normal file

@ -0,0 +1,3 @@
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
var CRC32 = {};

5
misc/99_footer.js Normal file

@ -0,0 +1,5 @@
export const version = CRC32.version;
export const table = T0;
export const bstr = crc32_bstr;
export const buf = crc32_buf;
export const str = crc32_str;

@ -1,10 +1,23 @@
var o = "foo bar baz٪☃🍣";
var m = "foobar"; for(var i = 0; i != 11; ++i) m+=m;
var m1 = m + m, m2 = m1 + m1, m3 = m2 + m2, m4 = m3 + m3;
var M1 = m + "𝑹" + m, M2 = M1 + "𝐀" + M1, M3 = M2 + "𝓜" + M2, M4 = M3 + "𝙖" + M3;
var bits = [
[ "foobar", -1628037227, 1 ],
[ "foo bar baz", -228401567, 1 ],
[ "foo bar baz٪", 984445192 ],
[ "foo bar baz٪☃", 140429620],
[ "foo bar baz٪☃🍣", 1531648243],
[ m, 40270464, 1 ]
[ m, 40270464, 1 ],
[ m1, -239917269, 1],
[ m2, 2048324365, 1 ],
[ m3, -1695517393, 1 ],
[ m4, 1625284864, 1 ],
[ M1, 642113519 ],
[ M2, -1441250016 ],
[ M3, -1101021992 ],
[ M4, -1610723860 ],
[ o, 1531648243 ],
[ o+o, -218791105 ],
[ o+o+o, 1834240887 ]
];
if(typeof module !== "undefined") module.exports = bits;

9
misc/flow.js Normal file

@ -0,0 +1,9 @@
/*::
declare class CRC32Module {
table:CRC32TableType;
bstr(s:string, seed?:CRC32Type):CRC32Type;
buf(b:ABuf, seed?:CRC32Type):CRC32Type;
str(s:string, seed?:CRC32Type):CRC32Type;
version:string;
};
*/

12
misc/flowdeps.js Normal file

@ -0,0 +1,12 @@
/*::
type _CB = {(data:Buffer):void;};
declare module 'concat-stream' {declare function exports(f:_CB):stream$Duplex;};
declare module 'exit-on-epipe' {};
declare module 'crc-32' { declare module.exports:CRC32Module; };
declare module '../' { declare module.exports:CRC32Module; };
declare module 'printj' {
declare function sprintf(fmt:string, ...args:any):string;
};
*/

42
misc/help.sh Executable file

@ -0,0 +1,42 @@
#!/bin/bash
# make_help.sh -- process listing of targets and special items in Makefile
# Copyright (C) 2016-present SheetJS
#
# usage in makefile: pipe the output of the following command:
# @grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST)
#
# lines starting with "## " are treated as subtitles
# lines starting with "#* " are treated as plaintext comments
# multiple targets with "## " after the ":" are rendered as separate targets
# if the presumed default target is labeled, it will be assigned a unique color
awk '
BEGIN{recipes=0;}
!/#[#*] .*$/ {next;}
{multi=0; isrecipe=0;}
/^[^#]*:/ {isrecipe=1; ++recipes;}
/^[^ :]* .*:/ {multi=1}
multi==0 && isrecipe>0 { if(recipes > 1) print; else print $0, "[default]"; next}
isrecipe == 0 {print; next}
multi>0 {
k=split($0, msg, "##"); m=split($0, a, ":"); n=split(a[1], b, " ");
for(i=1; i<=n; ++i) print b[i] ":", "##" msg[2], (recipes==1 && i==1 ? "[default]" : "")
}
END {}
' | if [[ -t 1 ]]; then
awk '
BEGIN {FS = ":.*?## "}
{color=36}
/\[default\]/ {color=35}
NF==1 && /^##/ {color=34}
NF==1 && /^#\*/ {color=20; $1 = substr($1, 4)}
{printf "\033[" color "m%-20s\033[0m %s\n", $1, $2;}
END{}' -
else
awk '
BEGIN {FS = ":.*?## "}
/^#\* / {$1 = substr($1, 4)}
{printf "%-20s %s\n", $1, $2;}
END{}' -
fi

@ -1,122 +0,0 @@
/* vim: set ts=2: */
if(typeof require !== 'undefined') {
var js_crc32 = require('../');
var js_crc32_old = require('crc-32');
var buffer_crc32 = require('./buffer-crc32');
var crc32 = require('./crc32');
var node_crc = require('./node-crc');
function z1(bstr) { return js_crc32.bstr(bstr); }
function z2(bstr) { return buffer_crc32.signed(bstr); }
function z3(bstr) { return crc32(bstr); }
function z4(bstr) { return node_crc.crc32(bstr);}
function z5(bstr) { return js_crc32_old.bstr(bstr); }
function b1(buf) { return js_crc32.buf(buf); }
function b2(buf) { return buffer_crc32.signed(buf); }
function b3(buf) { return crc32(buf); }
function b4(buf) { return node_crc.crc32(buf); }
function b5(buf) { return js_crc32_old.buf(buf); }
function u1(str) { return js_crc32.str(str); }
function u2(str) { return buffer_crc32.signed(str); }
function u3(str) { return js_crc32_old.str(str); }
var ntests, len_max, do_bstr, do_buf, do_ustr;
switch(process.env.MODE) {
case "A": ntests = 100000; len_max = 256; break;
case "B": ntests = 10000; len_max = 1024; break;
case "C": ntests = 10000; len_max = 4096; break;
case "D": ntests = 1000; len_max = 16384; break;
case "E": ntests = 1000; len_max = 65536; break;
case "F": ntests = 100; len_max = 262144; break;
default: ntests = 10000; len_max = 1024; break;
}
if(process.argv === 2) do_bstr = do_buf = do_ustr = true;
else {
do_bstr = process.argv[2].indexOf("S") > -1;
do_buf = process.argv[2].indexOf("B") > -1;
do_ustr = process.argv[2].indexOf("U") > -1;
if(!do_bstr && !do_buf && !do_ustr) do_bstr = do_buf = do_ustr = true;
}
var btest = !!do_bstr || !!do_buf, utest = !!do_ustr;
var bstr_tests = [];
var ustr_tests = [];
var len_min = 1;
var corpus = new Array(0x0800);
for(var k = 0; k < 0x0800; ++k) corpus[k] = String.fromCharCode(k)
len_max --;
k = (Math.random()*0x800)|0;
for(var i = 0; i < ntests; ++i) {
var l = (Math.random() * (len_max - len_min))|0 + len_min;
var s = new Array(l), t = new Array(l);
if(btest) for(var j = 0; j < l; ++j) s[j] = corpus[(i+j+k)&127];
if(utest) for(var j = 0; j < l; ++j) t[j] = corpus[(i+j+k)&0x7FF];
var ss = s.join("");
bstr_tests[i] = [ss, new Buffer(ss)];
ustr_tests[i] = t.join("");
}
var assert = require('assert');
function fix(str) { return parseInt(str, 16)|0; }
if(btest) for(var j = 0; j != ntests; ++j) {
if(do_bstr && do_buf) assert.equal(z1(bstr_tests[j][0]), b1(bstr_tests[j][1]));
if(do_bstr) {
assert.equal(z1(bstr_tests[j][0]), z2(bstr_tests[j][0]));
assert.equal(z1(bstr_tests[j][0]), fix(z3(bstr_tests[j][0])));
assert.equal(z1(bstr_tests[j][0]), fix(z4(bstr_tests[j][0])));
assert.equal(z1(bstr_tests[j][0]), z5(bstr_tests[j][0]));
}
if(do_buf) {
assert.equal(b1(bstr_tests[j][1]), b2(bstr_tests[j][1]));
assert.equal(b1(bstr_tests[j][1]), fix(b3(bstr_tests[j][1])));
assert.equal(b1(bstr_tests[j][1]), fix(b4(bstr_tests[j][1])));
assert.equal(b1(bstr_tests[j][1]), b5(bstr_tests[j][1]));
}
}
if(utest) for(var j = 0; j != ntests; ++j) {
assert.equal(u1(ustr_tests[j]), u2(ustr_tests[j]));
assert.equal(u1(ustr_tests[j]), u3(ustr_tests[j]));
}
var BM = require('../perf/bm');
if(do_bstr) {
var suite = new BM('binary string (' + len_max + ')');
suite.add('js-crc32', function() { for(var j = 0; j != ntests; ++j) z1(bstr_tests[j][0]); });
suite.add('js-crc32-old', function() { for(var j = 0; j != ntests; ++j) z5(bstr_tests[j][0]); });
suite.add('buffer-crc32', function() { for(var j = 0; j != ntests; ++j) z2(bstr_tests[j][0]); });
if(len_max < 4096) {
suite.add('crc32', function() { for(var j = 0; j != ntests; ++j) z3(bstr_tests[j][0]); });
suite.add('node_crc', function() { for(var j = 0; j != ntests; ++j) z4(bstr_tests[j][0]); });
}
suite.run();
}
if(do_buf) {
suite = new BM('buffer (' + len_max + ')');
suite.add('js-crc32', function() { for(var j = 0; j != ntests; ++j) b1(bstr_tests[j][1]); });
suite.add('js-crc32-old', function() { for(var j = 0; j != ntests; ++j) b5(bstr_tests[j][1]); });
suite.add('buffer-crc32', function() { for(var j = 0; j != ntests; ++j) b2(bstr_tests[j][1]); });
if(len_max < 1024) {
suite.add('crc32', function() { for(var j = 0; j != ntests; ++j) b3(bstr_tests[j][1]); });
suite.add('node_crc', function() { for(var j = 0; j != ntests; ++j) b4(bstr_tests[j][1]); });
}
suite.run();
}
if(do_ustr) {
var suite = new BM('unicode string (' + len_max + ')');
suite.add('js-crc32', function() { for(var j = 0; j != ntests; ++j) u1(ustr_tests[j]); });
suite.add('js-crc32-old', function() { for(var j = 0; j != ntests; ++j) u3(ustr_tests[j]); });
suite.add('buffer-crc32', function() { for(var j = 0; j != ntests; ++j) u2(ustr_tests[j]); });
suite.run();
}
}

48
misc/make_baseline.sh Executable file

@ -0,0 +1,48 @@
#!/bin/bash
# make_baseline.sh -- generate baselines for tests
# Copyright (C) 2016-present SheetJS
OUTD=../test_files
CATURL=https://mathias.html5.org/data/unicode/8.0.0/categories/
CATF=$OUTD/uccat.txt
ECHORED() { echo -ne '\x1B[0;31m'; echo -n "$1"; echo -ne '\x1B[0m'; echo; }
if [[ "$1" == "clean" ]]; then
if [ ! -d test_files ]; then cd ..; fi
if [ -d test_files ]; then cd test_files; fi
rm -f uccat.txt baseline.*.txt uctable.*.js uctable_*.py
exit
fi
# shellcheck disable=SC2164
if [ -d misc ]; then cd misc; fi
mkdir -p $OUTD
if [ ! -e $CATF ]; then curl "$CATURL" | grep "code-points" | sed 's/.*="//g;s/-.*//g' > $CATF; fi
while read -r line; do
JSF=uctable.${line}.js
PYF=uctable_${line}.py
BLF=baseline.${line}.txt
JSURL="https://mathias.html5.org/data/unicode/format?version=8.0.0&category=${line}&type=symbols&prepend=var+unicode%20%3D%20&append=%3Bif(typeof%20module%20!%3D%3D%20'undefined')%20module.exports%20%3D%20unicode%3B"
if [[ ! -e $OUTD/$JSF || ! -e $OUTD/$PYF || ! -e $OUTD/$BLF ]]; then
ECHORED "Processing ${line}"
for i in $JSF $PYF $BLF; do if [[ ! -e $i && -e $OUTD/$i ]]; then mv $OUTD/"$i" .; fi done
if [ ! -e "$JSF" ]; then
rm -f "$PYF" "$BLF" "${PYF}c"
echo "Downloading JS"
</dev/null curl -o "$JSF" "$JSURL"
fi
if [ ! -e "$PYF" ]; then
echo "Building Python script"
rm -f "$BLF" "${PYF}c"
</dev/null node make_unicode.njs "${line}" | sed 's/\[ \[/uctable = \[ \[/' > "$PYF"
fi
if [ ! -e "$BLF" ]; then
echo "Building Baseline text"
python make_unicode_crc.py "${line}" > "baseline.${line}.txt"
fi
for i in $JSF $PYF $BLF; do if [ -e "$i" ]; then mv "$i" $OUTD/; fi; done
rm -f "uctable_${line}.pyc"
fi
done < $CATF

14
misc/make_unicode.njs Normal file

@ -0,0 +1,14 @@
#!/usr/bin/env node
/* make_unicode.njs -- generate baselines for tests
* Copyright (C) 2016-present SheetJS
* vim: set ft=javascript: */
var argv = process.argv.slice(2);
var enc = require('codepage').utils.encode;
function arr(x) { return [].slice.call(enc(65001, x)); }
var o = require('./uctable.' + argv[0]).map(arr);
/* node 6 changed default behavior for arrays */
if(+process.version.replace(/v(\d)+\..*/,"$1") >= 6) o = require("util").inspect(o, {maxArrayLength: null});
console.log(o);

19
misc/make_unicode_crc.py Normal file

@ -0,0 +1,19 @@
#!/usr/bin/env python
# make_unicode_crc.py -- generate baselines for tests
# Copyright (C) 2016-present SheetJS
from zlib import crc32
from array import array
from sys import argv, stderr, exit
from importlib import import_module
args = argv[1:]
if len(args) < 1:
print >>stderr, "usage: " + argv[0] + " <category>"
exit(1)
uctable = import_module("uctable_" + args[0]).uctable
for z in uctable:
print crc32(array('B', z));

6
misc/mjs.lst Normal file

@ -0,0 +1,6 @@
misc/00_header.js
bits/01_version.js
bits/10_types.js
bits/20_crctable.js
bits/40_crc.js
misc/99_footer.js

@ -1,18 +0,0 @@
#!/bin/bash
cd misc &>/dev/null
git_module() {
if [ ! -e "$1/" ]; then git clone $2; fi
cd "$1"
git pull
cd - &>/dev/null
}
echo "::: downloading modules"
npm install crc-32 2>/dev/null
git_module node-crc https://github.com/alexgorbatchev/node-crc 2>/dev/null # crc
git_module crc32 https://github.com/beatgammit/crc32 2>/dev/null # crc32
git_module buffer-crc32 https://github.com/brianloveswords/buffer-crc32 2>/dev/null # buffer-crc32
for i in A B C D E F; do MODE="$i" node integration.js "$1"; done

@ -1,6 +1,6 @@
#!/bin/bash
# spin.sh -- show a spinner (for coverage test)
# Copyright (C) 2014 SheetJS
# Copyright (C) 2014-present SheetJS
wpid=$1
delay=1

@ -1,26 +1,59 @@
{
"name": "crc-32",
"version": "0.2.1",
"version": "1.2.3",
"author": "sheetjs",
"description": "Pure-JS CRC-32",
"keywords": [ "crc32", "checksum", "crc" ],
"main": "./crc32",
"devDependencies": {
"mocha":"",
"xlsjs":"",
"uglify-js":"",
"codepage":""
"keywords": [ "crc", "crc32", "checksum" ],
"bin": {
"crc32": "bin/crc32.njs"
},
"repository": { "type":"git", "url":"git://github.com/SheetJS/js-crc32.git" },
"main": "crc32.js",
"module": "crc32.mjs",
"types": "types/index.d.ts",
"typesVersions": { "*": { "*": ["types/index.d.ts" ] } },
"exports": {
".": {
"import": "./crc32.mjs",
"require": "./crc32.js"
},
"./crc32c": {
"import": "./crc32c.mjs",
"require": "./crc32c.js"
},
"./crc32.mjs": {
"import": "./crc32.mjs"
},
"./crc32c.mjs": {
"import": "./crc32c.mjs"
}
},
"dependencies": {
},
"devDependencies": {
"printj": "~1.3.1",
"exit-on-epipe": "~1.0.1",
"mocha": "~2.5.3",
"blanket": "~1.2.3",
"codepage": "~1.10.0",
"@sheetjs/uglify-js": "~2.7.3",
"@types/node": "^8.0.7",
"dtslint": "^0.1.2",
"typescript": "2.2.0"
},
"repository": { "type": "git", "url": "git://github.com/SheetJS/js-crc32.git" },
"scripts": {
"pretest": "git submodule init && git submodule update",
"test": "make test"
"test": "make test",
"build": "make",
"lint": "make fullint",
"dtslint": "dtslint types"
},
"config": {
"blanket": {
"pattern": "crc32.js"
}
},
"homepage": "https://sheetjs.com/",
"files": ["crc32.js", "crc32c.js", "crc32.mjs", "crc32c.mjs", "bin/crc32.njs", "LICENSE", "README.md", "types/index.d.ts", "types/*.json"],
"bugs": { "url": "https://github.com/SheetJS/js-crc32/issues" },
"license": "Apache-2.0",
"engines": { "node": ">=0.8" }

@ -0,0 +1 @@
*.tgz

@ -0,0 +1,9 @@
#!/usr/bin/env node
/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* vim: set ts=2 ft=javascript: */
/*jshint node:true */
var cli = require('../');
cli();

@ -0,0 +1,94 @@
/* index.js (C) 2020-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* vim: set ts=2 ft=javascript: */
/*jshint node:true */
/*:CRC32Module*/
var X = require('crc-32');
function help()/*:number*/ {
[
"usage: crc32 [options] [filename]",
"",
"Options:",
" -h, --help output usage information",
" -V, --version output the version number",
" -S, --seed=<n> use integer seed as starting value (rolling CRC)",
" -H, --hex-seed=<h> use hex seed as starting value (rolling CRC)",
" -d, --signed print result with format `%d` (default)",
" -u, --unsigned print result with format `%u`",
" -x, --hex print result with format `%0.8x`",
" -X, --HEX print result with format `%0.8X`",
" -c, --crc32c use CRC32C (Castagnoli)",
" -F, --format=<s> use specified printf format",
"",
"Set filename = '-' or pipe data into crc32 to read from stdin",
"Default output mode is signed (-d)",
""
].forEach(function (l) { console.log(l); });
return 0;
}
function version()/*:number*/ { console.log(X.version); return 0; }
var fs = require('fs');
require('exit-on-epipe');
function die(msg/*:string*/, ec/*:?number*/)/*:void*/ { console.error(msg); process.exit(ec || 0); }
function run() {
var args/*:Array<string>*/ = process.argv.slice(2);
var filename/*:string*/ = "";
var fmt/*:string*/ = "";
var seed = 0, r = 10;
for(var i = 0; i < args.length; ++i) {
var arg = args[i];
if(arg.charCodeAt(0) != 45) { if(filename === "") filename = arg; continue; }
var m = arg.indexOf("=") == -1 ? arg : arg.substr(0, arg.indexOf("="));
switch(m) {
case "-": filename = "-"; break;
case "--help": case "-h": process.exit(help()); break;
case "--version": case "-V": process.exit(version()); break;
case "--crc32c": case "-c": try { X = require('../crc32c'); } catch(e) { X = require('crc-32/crc32c'); } break;
case "--signed": case "-d": fmt = "%d"; break;
case "--unsigned": case "-u": fmt = "%u"; break;
case "--hex": case "-x": fmt = "%0.8x"; break;
case "--HEX": case "-X": fmt = "%0.8X"; break;
case "--format": case "-F":
fmt = ((m!=arg) ? arg.substr(m.length+1) : args[++i])||""; break;
case "--hex-seed": case "-H": r = 16;
/* falls through */
case "--seed": case "-S":
seed=parseInt((m!=arg) ? arg.substr(m.length+1) : args[++i], r)||0; break;
default: die("crc32: unrecognized option `" + arg + "'", 22);
}
}
if(!process.stdin.isTTY) filename = filename || "-";
if(filename.length===0) die("crc32: must specify a filename ('-' for stdin)",1);
var crc32 = seed;
// $FlowIgnore -- Writable is callable but type sig disagrees
var writable = require('stream').Writable();
writable._write = function(chunk, e, cb) { crc32 = X.buf(chunk, crc32); cb(); };
writable._writev = function(chunks, cb) {
chunks.forEach(function(c) { crc32 = X.buf(c.chunk, crc32);});
cb();
};
writable.on('finish', function() {
console.log(fmt === "" ? crc32 : require("printj").sprintf(fmt, crc32));
});
if(filename === "-") process.stdin.pipe(writable);
else if(fs.existsSync(filename)) fs.createReadStream(filename).pipe(writable);
else die("crc32: " + filename + ": No such file or directory", 2);
}
module.exports = run;

@ -0,0 +1,16 @@
{
"name": "crc32-cli",
"version": "1.0.1",
"author": "sheetjs",
"description": "Command-line interface for crc32",
"bin": {
"crc32-cli": "bin/crc32.njs"
},
"main": "index.js",
"dependencies": {
"crc-32": "^1.2.1",
"exit-on-epipe": "~1.0.1"
},
"license": "Apache-2.0"
}

@ -1,82 +0,0 @@
--- binary string (255) ---
✓ js-crc32 x 25.41 ops/sec ±0.40% (45 runs sampled)
✓ buffer-crc32 x 6.63 ops/sec ±1.09% (20 runs sampled)
✓ crc32 x 0.84 ops/sec ±1.17% (6 runs sampled)
✓ node_crc x 1.99 ops/sec ±0.59% (8 runs sampled)
Fastest is js-crc32
--- buffer (255) ---
✓ js-crc32 x 30.68 ops/sec ±0.40% (55 runs sampled)
✓ buffer-crc32 x 26.15 ops/sec ±0.36% (47 runs sampled)
✓ crc32 x 7.58 ops/sec ±0.61% (22 runs sampled)
✓ node_crc x 3.51 ops/sec ±0.56% (12 runs sampled)
Fastest is js-crc32
--- unicode string (255) ---
✓ js-crc32 x 11.65 ops/sec ±0.35% (32 runs sampled)
✓ buffer-crc32 x 3.17 ops/sec ±4.01% (12 runs sampled)
Fastest is js-crc32
--- binary string (1023) ---
✓ js-crc32 x 65.10 ops/sec ±0.36% (68 runs sampled)
✓ buffer-crc32 x 25.63 ops/sec ±3.38% (60 runs sampled)
✓ crc32 x 2.52 ops/sec ±0.65% (10 runs sampled)
✓ node_crc x 9.41 ops/sec ±0.55% (27 runs sampled)
Fastest is js-crc32
--- buffer (1023) ---
✓ js-crc32 x 78.58 ops/sec ±0.42% (82 runs sampled)
✓ buffer-crc32 x 73.15 ops/sec ±0.41% (76 runs sampled)
✓ crc32 x 21.28 ops/sec ±0.37% (39 runs sampled)
✓ node_crc x 12.46 ops/sec ±0.42% (34 runs sampled)
Fastest is js-crc32
--- unicode string (1023) ---
✓ js-crc32 x 29.07 ops/sec ±0.51% (51 runs sampled)
✓ buffer-crc32 x 9.25 ops/sec ±6.61% (35 runs sampled)
Fastest is js-crc32
--- binary string (4095) ---
✓ js-crc32 x 16.57 ops/sec ±0.47% (44 runs sampled)
✓ buffer-crc32 x 13.30 ops/sec ±8.05% (34 runs sampled)
✓ crc32 x 0.60 ops/sec ±0.46% (5 runs sampled)
✓ node_crc x 3.01 ops/sec ±0.52% (11 runs sampled)
Fastest is js-crc32
--- buffer (4095) ---
✓ js-crc32 x 20.35 ops/sec ±0.45% (37 runs sampled)
✓ buffer-crc32 x 18.86 ops/sec ±0.45% (50 runs sampled)
Fastest is js-crc32
--- unicode string (4095) ---
✓ js-crc32 x 7.20 ops/sec ±0.96% (22 runs sampled)
✓ buffer-crc32 x 4.20 ops/sec ±5.73% (13 runs sampled)
Fastest is js-crc32
--- binary string (16383) ---
✓ js-crc32 x 41.40 ops/sec ±0.15% (55 runs sampled)
✓ buffer-crc32 x 39.18 ops/sec ±5.86% (63 runs sampled)
Fastest is js-crc32
--- buffer (16383) ---
✓ js-crc32 x 51.36 ops/sec ±0.34% (67 runs sampled)
✓ buffer-crc32 x 47.72 ops/sec ±0.31% (63 runs sampled)
Fastest is js-crc32
--- unicode string (16383) ---
✓ js-crc32 x 18.47 ops/sec ±0.74% (49 runs sampled)
✓ buffer-crc32 x 11.29 ops/sec ±3.94% (31 runs sampled)
Fastest is js-crc32
--- binary string (65535) ---
✓ js-crc32 x 10.14 ops/sec ±4.43% (28 runs sampled)
✓ buffer-crc32 x 7.29 ops/sec ±5.49% (27 runs sampled)
Fastest is js-crc32
--- buffer (65535) ---
✓ js-crc32 x 12.34 ops/sec ±0.26% (34 runs sampled)
✓ buffer-crc32 x 11.29 ops/sec ±0.56% (32 runs sampled)
Fastest is js-crc32
--- unicode string (65535) ---
✓ js-crc32 x 4.28 ops/sec ±1.17% (14 runs sampled)
✓ buffer-crc32 x 2.73 ops/sec ±3.73% (10 runs sampled)
Fastest is js-crc32
--- binary string (262143) ---
✓ js-crc32 x 21.41 ops/sec ±3.43% (43 runs sampled)
✓ buffer-crc32 x 23.56 ops/sec ±4.02% (41 runs sampled)
Fastest is js-crc32
--- buffer (262143) ---
✓ js-crc32 x 31.51 ops/sec ±0.49% (55 runs sampled)
✓ buffer-crc32 x 27.56 ops/sec ±0.60% (51 runs sampled)
Fastest is js-crc32
--- unicode string (262143) ---
✓ js-crc32 x 11.00 ops/sec ±0.98% (31 runs sampled)
✓ buffer-crc32 x 6.70 ops/sec ±2.99% (19 runs sampled)
Fastest is js-crc32

@ -1,10 +1,14 @@
/* bm.js (C) 2014 SheetJS -- http://sheetjs.com */
/* bm.js (C) 2014-present SheetJS -- http://sheetjs.com */
var Benchmark = require('benchmark');
var c = require('ansi')(process.stdout);
function test_end(e) { c.horizontalAbsolute(0).write("✓ "+e.target); c.write('\n'); }
function suite_end() { console.log('Fastest is ' + this.filter('fastest').pluck('name')); }
function suite_end() {
var o = this.filter('fastest');
var m = typeof o.pluck === 'undefined' ? o.map('name') : o.pluck('name');
console.log('Fastest is ' + m);
}
function test_cycle(e) { c.horizontalAbsolute(0); c.eraseLine(); c.write("→ "+e.target); }
@ -25,9 +29,9 @@ BM.prototype.run = function(skip) {
BM.prototype.add = function(msg, test) {
this.suites.push([msg, {
onCycle: test_cycle,
onCycle: test_cycle,
onComplete: test_end,
defer: false,
defer: false,
fn: test
}]);
this.maxlen = Math.max(this.maxlen, msg.length);

@ -1,4 +1,6 @@
var table = require('../').table;
var old = require('crc-32').bstr;
var cur = require('../').bstr;
function strToArr(str) {
// sweet hack to turn string into a 'byte' array
@ -36,6 +38,14 @@ function node_crc32(bstr) {
return crcTable(strToArr(bstr));
}
function sheetjsB(bstr) {
var b = new Buffer(bstr, 'binary');
for(var crc = -1, i = 0; i < b.length; ++i) {
crc = (crc >>> 8) ^ table[(crc ^ b[i]) & 0xFF];
}
return crc ^ -1;
}
function sheetjs1(bstr) {
for(var crc = -1, i = 0; i < bstr.length; ++i) {
crc = (crc >>> 8) ^ table[(crc ^ bstr.charCodeAt(i)) & 0xFF];
@ -78,26 +88,34 @@ function sheetjs8(bstr) {
return crc ^ -1;
}
var w = 2000;
var base = new Array(w);
for(var i = 0; i !== w; ++i) base[i] = String.fromCharCode((Math.random()*256)&255);
var w = 80000;
var b = new Array(w);
for(var i = 0; i !== w; ++i) b[i] = ""+base.slice(0,i).join("");
b[0] = "";
for(var i = 1; i !== w; ++i) b[i] = b[i-1] + String.fromCharCode((Math.random()*256)&255);
var assert = require('assert');
for(var i = 0; i !== w; ++i) {
var foobar = b[i];
assert.equal(node_crc32(foobar), sheetjs1(foobar));
assert.equal(node_crc32(foobar), sheetjs2(foobar));
assert.equal(node_crc32(foobar), sheetjs3(foobar));
assert.equal(node_crc32(foobar), sheetjs8(foobar));
function check(foobar) {
var baseline = old(foobar);
assert.equal(baseline, sheetjs1(foobar));
assert.equal(baseline, sheetjs2(foobar));
assert.equal(baseline, sheetjs3(foobar));
assert.equal(baseline, sheetjs8(foobar));
assert.equal(baseline, sheetjsB(foobar));
assert.equal(baseline, cur(foobar));
if(i < 100) assert.equal(baseline, node_crc32(foobar));
}
for(var i = 0; i !== w; ++i) {
var foobar = b[i];
}
var BM = require('./bm');
var suite = new BM('binary string');
suite.add('npm crc32', function() { for(var j = 0; j !== w; ++j) node_crc32(b[j]); });
suite.add('sheetjs 1', function() { for(var j = 0; j !== w; ++j) sheetjs1(b[j]); });
suite.add('sheetjs 2', function() { for(var j = 0; j !== w; ++j) sheetjs2(b[j]); });
suite.add('sheetjs 3', function() { for(var j = 0; j !== w; ++j) sheetjs3(b[j]); });
suite.add('sheetjs 8', function() { for(var j = 0; j !== w; ++j) sheetjs8(b[j]); });
suite.add('sheetjs 1', function() { for(var j = 0; j !== w; j+=100) sheetjs1(b[j]); });
suite.add('sheetjs 2', function() { for(var j = 0; j !== w; j+=100) sheetjs2(b[j]); });
suite.add('sheetjs 3', function() { for(var j = 0; j !== w; j+=100) sheetjs3(b[j]); });
suite.add('sheetjs 8', function() { for(var j = 0; j !== w; j+=100) sheetjs8(b[j]); });
suite.add('sheetjs B', function() { for(var j = 0; j !== w; j+=100) sheetjsB(b[j]); });
suite.add('last vers', function() { for(var j = 0; j !== w; j+=100) old(b[j]); });
suite.add('current v', function() { for(var j = 0; j !== w; j+=100) cur(b[j]); });
suite.run();

@ -1,44 +1,73 @@
var table = require('../').table;
var T = require('../').table;
var old = require('crc-32').str;
var cur = require('../').str;
function sheetjs1(utf8) {
var buf = new Buffer(utf8);
for(var crc = -1, i = 0; i != buf.length; ++i) {
crc = (crc >>> 8) ^ table[(crc ^ buf[i]) & 0xFF];
for(var C = -1, i = 0; i != buf.length; ++i) {
C = (C >>> 8) ^ T[(C ^ buf[i]) & 0xFF];
}
return crc ^ -1;
return C ^ -1;
}
function sheetjs2(utf8) {
for(var crc = -1, i = 0, L=utf8.length, c, d; i < L;) {
c = utf8.charCodeAt(i++);
function sheetjs2(str) {
var C = -1;
for(var i = 0, L=str.length, c, d; i < L;) {
c = str.charCodeAt(i++);
if(c < 0x80) {
crc = (crc >>> 8) ^ table[(crc ^ c) & 0xFF];
C = (C>>>8) ^ T[(C ^ c)&0xFF];
} else if(c < 0x800) {
crc = (crc >>> 8) ^ table[(crc ^ (192|((c>>6)&31))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(c&63))) & 0xFF];
C = (C>>>8) ^ T[(C ^ (192|((c>>6)&31)))&0xFF];
C = (C>>>8) ^ T[(C ^ (128|(c&63)))&0xFF];
} else if(c >= 0xD800 && c < 0xE000) {
c = (c&1023)+64; d = utf8.charCodeAt(i++) & 1023;
crc = (crc >>> 8) ^ table[(crc ^ (240|((c>>8)&7))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((c>>2)&63))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((d>>6)&15)|(c&3))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(d&63))) & 0xFF];
c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
C = (C>>>8) ^ T[(C ^ (240|((c>>8)&7)))&0xFF];
C = (C>>>8) ^ T[(C ^ (128|((c>>2)&63)))&0xFF];
C = (C>>>8) ^ T[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
C = (C>>>8) ^ T[(C ^ (128|(d&63)))&0xFF];
} else {
crc = (crc >>> 8) ^ table[(crc ^ (224|((c>>12)&15))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|((c>>6)&63))) & 0xFF];
crc = (crc >>> 8) ^ table[(crc ^ (128|(c&63))) & 0xFF];
C = (C>>>8) ^ T[(C ^ (224|((c>>12)&15)))&0xFF];
C = (C>>>8) ^ T[(C ^ (128|((c>>6)&63)))&0xFF];
C = (C>>>8) ^ T[(C ^ (128|(c&63)))&0xFF];
}
}
return crc ^ -1;
return C ^ -1;
}
var BM = require('./bm');
var suite = new BM('unicode string');
var foobar = "foo bar baz٪☃🍣";
for(var i = 0; i != 4; ++i) foobar += " " + foobar;
var assert = require('assert');
function check(foobar) {
var baseline = old(foobar);
assert.equal(baseline, sheetjs1(foobar));
assert.equal(baseline, sheetjs2(foobar));
assert.equal(baseline, cur(foobar));
}
var BM = require('./bm');
var suite = new BM('unicode string (' + foobar.length + ')');
suite.add('sheetjs 1', function() { for(var j = 0; j != 1000; ++j) sheetjs1(foobar); });
suite.add('sheetjs 2', function() { for(var j = 0; j != 1000; ++j) sheetjs2(foobar); });
suite.run()
var assert = require('assert');
assert.equal(sheetjs1(foobar), sheetjs2(foobar));
suite.add('last vers', function() { for(var j = 0; j != 1000; ++j) old(foobar, 0) ; });
suite.add('current v', function() { for(var j = 0; j != 1000; ++j) cur(foobar, 0); });
suite.run();
function doit(foobar) {
check(foobar);
var s = new BM('unicode string (' + foobar.length + ')');
s.add('sheetjs 1', function() { sheetjs1(foobar); });
s.add('sheetjs 2', function() { sheetjs2(foobar); });
s.add('last vers', function() { old(foobar, 0); });
s.add('current v', function() { cur(foobar, 0); });
s.run();
}
for(var i = 0; i != 4; ++i) foobar += " " + foobar;
doit(foobar);
foobar += " " + foobar;
doit(foobar);
foobar += " " + foobar;
doit(foobar);

237
shim.js Normal file

@ -0,0 +1,237 @@
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
if (!Object.keys) {
Object.keys = (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
],
dontEnumsLength = dontEnums.length;
return function (obj) {
if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) throw new TypeError('Object.keys called on non-object');
var result = [];
for (var prop in obj) {
if (hasOwnProperty.call(obj, prop)) result.push(prop);
}
if (hasDontEnumBug) {
for (var i=0; i < dontEnumsLength; i++) {
if (hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i]);
}
}
return result;
};
})();
}
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp */)
{
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var res = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in t)
{
var val = t[i]; // in case fun mutates this
if (fun.call(thisp, val, i, t))
res.push(val);
}
}
return res;
};
}
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, '');
};
}
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
if (!Array.prototype.forEach)
{
Array.prototype.forEach = function(fun /*, thisArg */)
{
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++)
{
if (i in t)
fun.call(thisArg, t[i], i, t);
}
};
}
// Production steps of ECMA-262, Edition 5, 15.4.4.19
// Reference: http://es5.github.com/#x15.4.4.19
if (!Array.prototype.map) {
Array.prototype.map = function(callback, thisArg) {
var T, A, k;
if (this == null) {
throw new TypeError(" this is null or not defined");
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== "function") {
throw new TypeError(callback + " is not a function");
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (thisArg) {
T = thisArg;
}
// 6. Let A be a new array created as if by the expression new Array(len) where Array is
// the standard built-in constructor with that name and len is the value of len.
A = new Array(len);
// 7. Let k be 0
k = 0;
// 8. Repeat, while k < len
while(k < len) {
var kValue, mappedValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[ k ];
// ii. Let mappedValue be the result of calling the Call internal method of callback
// with T as the this value and argument list containing kValue, k, and O.
mappedValue = callback.call(T, kValue, k, O);
// iii. Call the DefineOwnProperty internal method of A with arguments
// Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true},
// and false.
// In browsers that support Object.defineProperty, use the following:
// Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
// For best browser support, use the following:
A[ k ] = mappedValue;
}
// d. Increase k by 1.
k++;
}
// 9. return A
return A;
};
}
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement, fromIndex) {
if ( this === undefined || this === null ) {
throw new TypeError( '"this" is null or not defined' );
}
var length = this.length >>> 0; // Hack to convert object.length to a UInt32
fromIndex = +fromIndex || 0;
if (Math.abs(fromIndex) === Infinity) {
fromIndex = 0;
}
if (fromIndex < 0) {
fromIndex += length;
if (fromIndex < 0) {
fromIndex = 0;
}
}
for (;fromIndex < length; fromIndex++) {
if (this[fromIndex] === searchElement) {
return fromIndex;
}
}
return -1;
};
}
// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
if (! Array.isArray) {
Array.isArray = function(obj) {
return Object.prototype.toString.call(obj) === "[object Array]";
};
}
// https://github.com/ttaubert/node-arraybuffer-slice
// (c) 2013 Tim Taubert <tim@timtaubert.de>
// arraybuffer-slice may be freely distributed under the MIT license.
"use strict";
if (typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) {
ArrayBuffer.prototype.slice = function (begin, end) {
begin = (begin|0) || 0;
var num = this.byteLength;
end = end === (void 0) ? num : (end|0);
// Handle negative values.
if (begin < 0) begin += num;
if (end < 0) end += num;
if (num === 0 || begin >= num || begin >= end) {
return new ArrayBuffer(0);
}
var length = Math.min(num - begin, end - begin);
var target = new ArrayBuffer(length);
var targetArray = new Uint8Array(target);
targetArray.set(new Uint8Array(this, begin, length));
return target;
};
}

84
test.js

@ -5,29 +5,97 @@ if(typeof require !== 'undefined') {
describe('source',function(){it('should load',function(){X=require('./');});});
bits = require('./misc/bits.js');
crc32table = require('./misc/table.js');
fs = require("fs");
} else { X = CRC32; }
function readlines(f) { return fs.readFileSync(f, "ascii").split("\n"); }
function msieversion()
{
if(typeof window == 'undefined') return Infinity;
if(typeof window.navigator == 'undefined') return Infinity;
var ua = window.navigator.userAgent
var msie = ua.indexOf ( "MSIE " )
if(msie < 0) return Infinity;
return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )));
}
var Buffer_from = function(){};
if(typeof Buffer !== 'undefined') {
var nbfs = !Buffer.from;
if(!nbfs) try { Buffer.from("foo", "utf8"); } catch(e) { nbfs = true; }
Buffer_from = nbfs ? function(buf, enc) { return (enc) ? new Buffer(buf, enc) : new Buffer(buf); } : Buffer.from.bind(Buffer);
}
describe('crc32 table', function() {
it('should match fixed table', function() {
var badness = 0;
var overflow = 0;
for(var i = 0; i != crc32table.length; ++i) {
assert.equal(crc32table[i]|0, X.table[i]);
if(crc32table[i] !== X.table[i]) ++badness;
if(crc32table[i] !== X.table[i]) ++overflow;
}
assert.equal(badness, 128);
assert.equal(overflow, 128);
});
});
describe('crc32 bits', function() {
bits.forEach(function(i) {
var l = i[0].length;
var msg = i[0];
var msg = i[0], l = i[0].length, L = i[1]|0;
if(l > 20) msg = i[0].substr(0,5) + "...(" + l + ")..." + i[0].substr(-5);
if(l > 100 && msieversion() < 9) return;
if(l > 20000 && typeof Buffer === 'undefined') return;
it(msg, function() {
if(i[2] === 1) assert.equal(X.bstr(i[0]), i[1]|0);
if(i[2] === 1) assert.equal(X.bstr(i[0]), L);
assert.equal(X.str(i[0]), i[1]|0);
if(typeof Buffer !== 'undefined') assert.equal(X.buf(new Buffer(i[0])), i[1]|0);
if(typeof Buffer !== 'undefined') assert.equal(X.buf(Buffer_from(i[0])), L);
var len = i[0].length, step = len < 20000 ? 1 : len < 50000 ? Math.ceil(len / 20000) : Math.ceil(len / 2000);
for(var x = 0; x < len; x += step) {
if(i[0].charCodeAt(x) >= 0xD800 && i[0].charCodeAt(x) < 0xE000) continue;
if(i[2] === 1) {
var bstrcrc = X.bstr(i[0].substr(x), X.bstr(i[0].substr(0, x)));
assert.equal(bstrcrc, L);
}
var strcrc = X.str(i[0].substr(x), X.str(i[0].substr(0, x)));
assert.equal(strcrc, i[1]|0);
if(typeof Buffer !== 'undefined') {
var buf = Buffer_from(i[0]);
var bufcrc = X.buf(buf.slice(x), X.buf(buf.slice(0, x)));
assert.equal(bufcrc, L);
}
}
});
});
});
if(typeof require !== 'undefined') describe("unicode", function() {
if(!fs.existsSync("./test_files/uccat.txt")) return;
var uccat = readlines("./test_files/uccat.txt");
uccat.forEach(function(cat) {
it("Category " + cat, function() {
if(!fs.existsSync("./test_files/baseline." + cat + ".txt")) return;
var corpus = readlines("./test_files/baseline." + cat + ".txt");
var uctable = require("./test_files/uctable." + cat + ".js");
for(var ucidx = 0; ucidx < uctable.length; ++ucidx) {
var c = uctable[ucidx];
/* since the baselines are passed via utf8, discard invalid codes */
if(c.charCodeAt(0) >= 0xD800 && c.charCodeAt(0) < 0xE000) continue;
var cc = corpus[ucidx], dd = X.str(c);
assert.equal(dd, cc, ":" + ucidx + ":" + c + ":" + cc + ":" + dd);
if(typeof Buffer !== 'undefined') {
var ee = X.buf(Buffer_from(c, "utf8"));
assert.equal(ee, cc, ":" + ucidx + ":" + c + ":" + cc + ":" + ee);
var ff = X.bstr(String.fromCharCode.apply(null, Buffer_from(c, "utf8")));
assert.equal(ff, cc, ":" + ucidx + ":" + c + ":" + cc + ":" + ff);
}
};
});
});
});
if(typeof require !== 'undefined') describe("corpora", function() {
require("./test_files/corpus.json").forEach(function(text) {
if(!fs.existsSync(text[1])) return;
it("should match '" + text[0] + "' (" + text[2] + ")", function() {
assert.equal(text[2], X.buf(fs.readFileSync(text[1])));
});
});
});

993590
test_files/baseline.C.txt Normal file

File diff suppressed because it is too large Load Diff

@ -0,0 +1,65 @@
-771559539
-1526341861
1007455905
1259060791
-714134636
-1570235646
996231864
1281784366
-589731905
-1411492055
852952723
1171273221
-608918618
-1397517520
901431946
1119744540
-810156055
-1196241025
565944005
1455205971
-925352976
-1075901594
651582172
1372678730
-1049724965
-1234614451
794826487
1483155041
-972835902
-1325104300
671994606
1594548856
314082080
1437410323
581571717
-1146927809
-861637207
1388371978
633852060
-1127317210
-875974224
1534503969
745643191
-1250374387
-1031799397
1545300024
723277998
-1307244268
-988661374
1209676919
1058866401
-1508616869
-787257907
1333260398
946913528
-1585868478
-696344108
1187101765
835095763
-1462772375
-540480001
1101822044
917194954
-1348331152
-660264474

150
test_files/baseline.Cf.txt Normal file

@ -0,0 +1,150 @@
275937382
-444539192
-1836585378
193904612
2089389938
-487777583
-1779815865
-243170681
-1381244462
290653789
-211390133
349052735
-1968534884
-38946294
1688529840
329505574
1487343457
799031287
-1312511404
-960259390
1607125880
-1586899138
-697374808
1332196882
945849988
-1509682393
1208644107
1057833629
-1347264756
-659198054
1102855712
918228662
-1461740779
-539448445
1188166201
836160175
17864673
-1944062000
353805930
1645319932
-409588092
1447162232
558285294
-1202745260
-817323838
1182100512
-669910653
-1357461227
908040367
1092134969
-777538136
-1499429570
1068094596
-841805624
-2118516586
-155373568
1874092474
414404908
-2032679793
-237964263
1759094179
534680885
-1889433436
-127485902
1634724232
375970078
-2012459843
-16024533
1711418769
285547783
-1676865294
-351657884
1912828382
84164936
-1688152853
-328735619
1970189767
40469841
-1831429952
-439244714
2094594540
199215482
-1782883111
-490967985
2075475445
212995427
-1546710753
-725081719
1304522803
986071205
-1532832506
-744102512
1252832298
1034650812
-1391158995
-636245573
1125840897
874367127
-1434886860
-578916958
1148664856
862981262
-1099431557
-914411027
1349935191
661737665
-1189755550
-837618188
1461429326
538744024
-1331459767
-945505825
1588455525
699062515
-1211216560
-1060536890
1505766524
784801002
-1734266409
-274333375
1991201019
27811949
-1613957682
-389298856
1908577506
113615988
-1770341915
-511866509
2020923593
259254367
-1860731396
-435139222
2132352208
136195142
-2062147149
-233762523
1796751519
471822345
-2105809494
-176368324
1819640966
460502032
-1949455999
-53831401
1707329709
314898491
-1935643240
-72917746
1655573684
363412514

853859
test_files/baseline.Cn.txt Normal file

File diff suppressed because it is too large Load Diff

137468
test_files/baseline.Co.txt Normal file

File diff suppressed because it is too large Load Diff

2048
test_files/baseline.Cs.txt Normal file

File diff suppressed because it is too large Load Diff

109591
test_files/baseline.L.txt Normal file

File diff suppressed because it is too large Load Diff

3646
test_files/baseline.LC.txt Normal file

File diff suppressed because it is too large Load Diff

1984
test_files/baseline.Ll.txt Normal file

File diff suppressed because it is too large Load Diff

248
test_files/baseline.Lm.txt Normal file

@ -0,0 +1,248 @@
-1146249545
-861229535
1436811163
581226253
-1128244562
-876123592
1389247362
633932564
-1250552187
-1032772077
1534621609
746538815
-1306799460
-987962870
1544926128
722633510
-2073059494
-211243060
1829517935
436931321
-1967909016
-38590466
1689941572
331171538
-1915104399
-86055961
1675080285
349209291
-1713860802
-287326296
-1090404462
-939094268
1359994558
638119464
-1200850037
-1229458503
1488556693
-209597335
339337582
876939333
-56889463
-2052499124
480250102
-1955218246
-59601876
1825411517
-394342655
689951402
547987073
968212996
1736391254
1430870228
-2062002262
-808193097
-1798554441
1262158253
1862649794
402847572
-2129942802
-166947208
1751647195
527381325
145287162
2142230380
-425294122
-1851673024
480885685
1806600995
-223880551
-2053051889
465862572
1824739130
-171303296
-2100482538
309474183
1702167313
-58961237
-1954848195
354416542
1645790984
-82733390
-1944672732
594262616
1416399566
-848962700
-1167922206
604405313
1392594647
-905437331
-1123078149
766521962
1521943292
-1010937018
-1262918704
719189619
1574618853
-992766113
-1277909047
1054648892
1239128746
-791491824
-1479148666
967929381
1320574643
-675344631
-1598537825
805773838
1191187096
-569818334
-1458670668
929752599
1080940161
-647723205
-1369196627
403020432
1862445574
-166986820
-2129867990
526933641
1752133151
-244957275
-2040459469
383652514
1641620020
-120556658
191431366
-2111627145
474461652
1799390530
-230042376
-2058427282
858310995
1143994821
-584669057
-1440638743
876940618
1128414684
-632591258
-1387504400
1039352161
1257533943
-738385843
-1527115557
983467384
1301919214
-728701868
-1550330686
782227767
1503193505
-1064191973
-1214871411
703733038
1593126328
-939754494
-1325708140
541348101
1464033683
-833998807
-1186135873
657036572
1345234314
-920128464
-1105148762
-874907700
744610507
-1398950831
-610630457
1116984701
898950635
-1410305976
-587775778
1174278500
855187954
-1572455325
-717157131
1279810895
995061209
-1523844998
1781448066
489262356
-1963181736
1062356757
-223062001
-754930502
1242168576
1024380310
-1553311691
-731027293
869615012
-739335461
1256715105
-2036563004
-241454254
1754456808
-523078684
-991793661
-1276813675
720113455
1575698361
-1013994982
-1266115956
111297405
-1603726550
690172315
1579417869
-391426155
2014597636
252928658
-1776667864
-518192194
2138674717
142517899
-1854408911
-428816473
1421527999
1469391074
1750540559
525341081
-948619013
-2050514793
-275761080
-1736898881
1152322416
-624189741
-1188785745
-836525767
1462431875
539869205
-940233226
806253562
1191789420
-1465037699
-542475029
1185099089
832839111
1308380209
-744957550
-1533023996
1033287870
1251051560
-634481223
-1389779665
874574997
1126679555
-582790752
-1438359242
860696716
1145700378

105697
test_files/baseline.Lo.txt Normal file

File diff suppressed because it is too large Load Diff

@ -0,0 +1,31 @@
1487938777
637622372
-1089992226
-535985706
-834344031
-1186735305
541756045
1464711707
-920047688
-1104273618
656887444
1344306690
-738985019
-1527461037
1040030441
1257941631
-727826468
-1550250166
982540016
1301769830
-181744791
-2110915585
455387717
1814272723
-230224016
-2059386906
474574428
1800298186
-269476076
-802021639
-152359339

1631
test_files/baseline.Lu.txt Normal file

File diff suppressed because it is too large Load Diff

1963
test_files/baseline.M.txt Normal file

File diff suppressed because it is too large Load Diff

383
test_files/baseline.Mc.txt Normal file

@ -0,0 +1,383 @@
-394681659
-1065674149
-1341002028
-954802622
1751892542
297237146
-2000803040
-4645962
1641909781
-1881936071
-120266833
-1387728687
-632307641
-2111337386
-182403904
1516085436
-1002883809
1418078350
-846235340
1407970455
-644995717
1154280905
480551384
1805881678
-992047822
1996132171
781370202
1502999500
-152506448
-1892395244
1631204920
-10574949
1470568539
547367117
2026398940
-1598928842
1054268821
-1368801276
929075646
-1459354595
593612273
1258161758
1039742664
-444392926
2089438104
2078773121
216055575
-1671454074
1917961130
89584444
-1691195745
290959219
685315260
-1311750906
-958958192
834807293
-1463061433
-540261167
1101582706
-2082068604
-186575086
-1400284413
1962113001
66340735
-1694689595
-302373293
1939780592
-359144886
2049507291
-1809408265
-484331935
422482690
-2144877896
-709066750
-1564757868
-86770555
-1915433965
581554287
-875924134
-1127397940
745691229
-1032046223
-1250227737
723491908
-1585818200
-410328448
-1869753834
-2145341572
220766857
2049937951
66267835
1962154541
-302167145
-1694860543
77524642
1939463732
-359624818
-1650999528
-666311827
-1353722885
839546509
1158497819
1544976218
770081198
-1283320819
-796624684
-1453801360
810652106
-1372257175
1821768958
462605416
1294010443
975583453
-1539134082
1028390084
-1376460459
-621555261
1140490361
889041135
-1432804020
-576842278
711281622
-1274945931
755535823
-1112042914
-894393656
1404695410
616481764
-1160096185
601032701
1309598486
956945280
-1486010845
-1700670808
-1803920742
-478320116
1275098736
990332646
-1576134820
-720820278
1265480297
1013613311
-765140013
1121713730
-757733318
1286700441
1001803023
-1564533579
838861092
-1425452898
-603037688
1449896420
560765298
-815597474
1359375869
637623659
-1089991471
-938525625
1487938006
-1200849276
560279358
-1463745554
1187996354
-1988757669
1736152695
-115407916
-2134656144
432728778
1858984540
-473573463
-1799166145
231454341
-1090070695
-287778973
157350500
-536649903
2030702315
235748989
-1586486783
-696839529
947483579
-1507989992
1683165422
-969645668
1481700415
794281129
1374074900
911013352
1224575317
1073396163
-1583469472
1334857036
1536233731
748036501
1646242508
353933914
-1944990752
-82379914
1806296807
481220209
-2052618293
-224348323
2141764264
145721918
962071936
-1108980642
-891192120
1577623887
688886233
-1158888737
612915068
-1115617594
717082927
1572528569
185148826
2081297676
-452508490
-1845464032
46098865
1975015719
-323942243
-1682556917
97693096
1926602046
-337851260
-1663304686
866574446
1151455480
-576159422
-1431326252
-1773848928
-515766730
-673692271
1868947614
409128968
-1998729831
-2425585
381245498
-1884288640
-122210026
1472865642
2072184060
-158660343
1870813363
-236532464
-1208454055
2017649088
-1860090635
1472434982
665413545
1353602879
-1379094971
1031069200
-1559213133
1293822623
974723593
-576637170
1151887028
-1379155071
-1916272617
1673945403
1374684089
-1725476295
-299867473
1999188757
121882522
-1745036789
-612587024
899466941
1682097799
-98151644
-1927191630
1844742828
-1031170352
2009720572
13555306
-1714976816
-1916347489
-87954679
329403964
1431501076
576047490
-1151559624
-814535113
-1200349535
-535014736
-1759813082
1331777228
-697819274
-1586548768
1057733187
-1509757959
918419048
-1347115054
835727985
1188496103
-1145701475
-318357570
-1711206616
-739950488
-1528663810
1038819652
-1439041332
1144494560
-632091581
-1386988331
878538095
-1692372717
981567641
-1215724180
-1064389126
-1185804962
-833274424
1465674866
542858468
1345431659
688564450
1577949300
-955987506
-1093111446
549250249
-827161115
255694383
-516688125
-1774925931
-228626603
1355906434
668355860
-1179461449
-1998618914
299249508
1724981234
-122320303
-1884112185
381414269
1639767019
-251410822
-2046494996
520988502
1745524672
-160562589
-2123812107
408970063
1869042649
-654213404
-1375318414
923738056
1074278238
-563299587
-1452570005
811785169
1197861703
-673515818
-1596078528
970233850
1322493804
-793300273
-1481637287
1052333027
1237214069
-994677120
-1280221674
716705708
1572814650
-1009014119
-1260611057
768986037
1523776291
-898767182
-1117071836
610502558
1399109384
-855629141
-1173941699
588137351
-1298015887
732465355
-1132834493
628293881
1383346287
-545505894
-1468330740
829578422

@ -0,0 +1,13 @@
297057904
1723043558
793815405
-885524051
1379837975
624531585
-1822444100
2102514832
173466630
-1808633435
819334843
1204895277
-556241001

1567
test_files/baseline.Mn.txt Normal file

File diff suppressed because it is too large Load Diff

1433
test_files/baseline.N.txt Normal file

File diff suppressed because it is too large Load Diff

550
test_files/baseline.Nd.txt Normal file

@ -0,0 +1,550 @@
-186917087
-2082672713
450215437
1842515611
-206169288
-2068763730
498629140
1790921346
-100641005
-1928894587
-940191935
-1326252073
704360045
1593614075
-1063777448
-1214301234
781609588
1502698210
-919713933
-1104578587
-395002457
-1619817167
108715147
1904077853
-283543106
-1742845656
18290834
1980770308
-424725099
-1851259645
-1430173681
-574195559
1154427171
868751797
-1381200874
-626279296
1134751034
883285420
-1541750723
-753012565
-1167702077
-849250475
1574857412
718887506
-1278211096
-992527490
1521725149
766811723
-1262628879
-1011155097
-2008013503
-11069993
1877477446
418330832
-2115606166
-153003524
1753599071
528678089
-2037666445
-242442779
382929103
1641298009
-244636216
-2039736994
526730468
1751282802
-167321135
-2130587321
403210493
1863299179
619014733
1407343323
-1017297078
-1269139492
760424038
1515460336
-1003453613
-1288195131
708764287
1564070633
1925172683
96009565
-1794645812
-503263142
2064220640
202289526
-1838537515
-445836221
2086946297
191067503
1082765129
932093919
-1489927602
-801721640
1228923746
1043911668
-1604565417
-681871679
1314006907
961877997
-1798795114
-472932352
1936768401
74943751
-1652630339
-361108437
1948088712
52054302
-1710024540
-317446094
-1493241324
-772160894
1095163667
910290821
-1354187201
-665874775
1177230090
824978332
-1473938906
-551400784
-257665646
-2019334908
387741845
1612400643
-116254279
-1911215825
275889292
1735822362
-25174624
-1988563658
-1030605040
-1248524410
623516183
1378691713
-886801605
-1138537555
575135246
1430318744
-867582174
-1152479308
-1817473273
-458440815
2108026411
178446013
-1798943970
-473859192
2059938354
231676580
-1653602507
-361285725
-1583485563
-694493933
1335069865
949271615
-1494210148
-772335350
1224624304
1073313830
-1354340937
-666807007
-939176978
-1090356360
638266050
1359747668
-815230985
-1200636063
560393947
1449254477
-958479396
-1311116470
-1740551761
-280594119
1984899203
21501973
-1624470090
-399786720
1898114202
103144460
-1768242787
-509742837
-1361376760
-639878498
1087728420
936532914
-1447637487
-558760313
1203285821
817864619
-1610579398
-687361364
2003719864
6907438
-1721747564
-295237886
1879282337
117744183
-1643252851
-385170661
2041962122
246607388
157895720
2121170110
-412668668
-1872749166
235178033
2030287015
-536155875
-1760700021
129156122
1890972812
-2134241988
-137544278
1735532603
276107437
-1988345577
-25464447
1612702754
387503284
-1911454450
-115952232
1177082607
825223801
-1473856573
-551449771
1095048950
910306912
-1354006566
-666087604
1223906013
1072980555
-298732346
-1724480432
4183530
2000217468
-379817761
-1638186935
122819059
1884627301
-521519884
-1746072478
-209279838
-2071882700
495502734
1787819288
-185900869
-2081664979
451215767
1843540225
-44225392
-1973806074
-1127796123
-876608781
1388925769
634282975
-1146423684
-861026582
1436850000
581150662
-1306740137
-988050751
-1400618642
-612142600
1116348482
898437332
-1410759305
-588335647
1172825179
853595341
-1570780836
-715589174
1191673692
805326794
-1459020176
-569495834
1080736581
929926099
-1369122199
-647763201
1239218030
1054590968
1521512248
766992302
-1262612972
-1011270014
1574808353
718969783
-1277965811
-992675173
1416357642
594335644
880422814
1132273416
-629911886
-1384939996
857205639
1141955345
-585528661
-1440826819
983672748
1302763322
772927498
1494663324
-1071673050
-1223122512
696005651
1585120389
-948808385
-1334483543
550139960
1473071278
2095543977
199247423
-1830217851
-437377261
2072687280
210600486
-1786457188
-494673142
1916599963
87805453
1249719566
1031407000
-1535945694
-747346764
1292955927
974635393
-1558278085
-736517971
1151778108
866225578
1897076166
101983568
-1625459478
-400931716
1988022751
24764745
-1737445133
-277381019
2143854068
147828066
-721545088
-1543952362
988838316
1308051770
-745284455
-1533744113
1033747893
1251642659
-635072334
-1390239708
-1177903154
-825381032
1472528098
549703284
-1096328233
-912233663
1353267963
665717357
-1223616516
-1072289942
-444580737
-1836643095
193879379
2089381317
-487720858
-1779775248
216242506
2078583260
-346311603
-1671658277
-812631493
-1198060883
564026135
1452895105
-922878430
-1074082124
653500174
1374990232
-1052003831
-1236499809
1189000363
836338749
-1587111508
-698242758
1332279424
946849814
-1509204555
-787714781
1208302745
1057098767
-2143526024
-147106834
1848771156
422916802
-2024691871
-262760457
1767884365
509146843
-1897403574
-102704164
639520906
1360617500
-1046053491
-1230942949
799546529
1487875127
-959727212
-1311995646
684054712
1606608942
-549550412
-1472612830
825288600
1178064654
-665632083
-1353420229
912073601
1096422167
-773517690
-1495122416
1223027056
1071831526
-1494513572
-773015350
1334324585
948903423
-1585034171
-696156973
1178493250
825840084
-242200095
-2036899465
530460877
1754857563
-151153160
-2114280082
418641108
1878312002
-11806253
-2008225467
192919915
2088274429
-445523897
-1837700911
202538354
2064993764
-501474210
-1793381176
94646617
1923285455
620678029
1408891675
-890197343
-1107846601
596840340
1419001602
-845320520
-1164288466
707085247
1562538793
1298558438
979459440
-1553462070
-730907556
1242278399
1024235881
-1543124781
-754780091
1136518612
884659522
135223230
2131257128
-436128110
-1861876220
258118567
2019926833
-512953717
-1771322851
114614156
1909714714
-139482703
-2136434393
430033053
1856436235
-255693400
-2017108674
516689028
1774926866
-109829757
-1905061611
-1256563687
-1038259057
1528053045
739446179
-1300785152
-982472554
1551497516
729729466
-1144925141
-859380547
-1372529942
-650646916
1413474185
590927647
-1171159387
-852052429
1397891984
609555206
-1118027076
-899976662
1524920251
769875757
-1259729257
-1007862271
1569303458
713988916
-1282946418
-998180328
1927730981
98690995
-1662470647
-336623969
1972048700
42738602
-1685753328
-327007610
2084396823
188379009
-1842135493
-449573203
2068880142
207072152
-1788937694
-497431884
1867630401
408352727
-2124437907
-161966341
1748763480
523973582
-2043518348
-248163614
1636454259
378372069
-1887162785
-125624631
1726450538
299940860
-1997936058
-1123632

236
test_files/baseline.Nl.txt Normal file

@ -0,0 +1,236 @@
-189088069
-2084729299
246776792
-989523398
-1308482900
722170646
1544307584
-1033316829
-1250957643
744929039
1533118361
-874604024
-1126585698
634452772
1389874098
-860660207
-1145803129
582827837
1438257067
-659422626
-1347079480
918315890
1102795748
-538982841
-1462176047
835823467
1188468733
-697726356
-1586578694
946334528
1331747798
-788246923
-1509720349
1057632089
1208819663
-716807887
-1572777561
994574365
-1523804738
1009107972
1260582034
-610408189
481966371
-826819362
1472130404
549051890
-1092794287
-908429113
1356015997
668211691
-1217723270
-1066650388
-1428417506
-572840824
1154643250
-164308632
-2127304194
294450287
1720435961
-8219325
-2004507179
383856758
1642463456
-118533798
-1880596020
-243425691
-2038780173
527695689
1752485855
-166700420
-2129171734
404634448
1863912390
-5892521
-2002704703
296253307
1722763245
-120860082
-1882397992
382055266
1640137716
-322269695
-1681015145
46460717
1975771067
-341358056
-1667204466
94972724
1924012962
-502200781
-1793706331
203384607
2065192841
-444808662
-1837370692
192062214
2088080272
-904675667
-1122726341
605937537
1394274071
-847349068
-1166456286
594549656
1417095950
-993511777
-1278278135
717641651
1572955941
-1012534650
-1264401904
766219178
1521263420
-677073207
-1599889825
967495653
1320025971
-792106288
1319314683
-646840973
1629640221
-131397721
-1892927695
289972882
1716490756
-984830945
-1303667575
725798195
1548090789
-1037998074
-1255778160
741280042
1529362876
-879287251
-1131408197
630801665
1386116503
-855973836
-1140993886
586449176
1442034062
-654590853
-1342403347
922082647
1106439617
-543786910
-1466873612
832051534
1184836056
-702532535
-1591278369
942560613
1328113139
-783421360
-1505050426
1061392764
1212457450
-31290153
-1994015679
271379963
1730927981
-112244530
-1907853224
390146530
1615206772
-252115739
-2013383565
519529929
1777358175
-141246212
-2137788310
429564368
1855820102
-476734285
-1802327003
228326815
2057096457
-453486422
-1811978180
183908742
2112948496
-313650047
-1706482665
54556077
1950827835
-366751592
-1658527730
70103476
1932165410
-598237858
-1420775992
844758130
1163840740
-616933049
-1405261359
892614763
1110640893
-762571412
-1517607430
1015182400
1267025110
-706621067
-1561927197
1005563993
1290305743
-1042248390
-1226326612
804187158
1491721344
-963819229
-1316324939
679684111
1602492569
-818215672
-1204013666
557147172
1446139058
-933838575
-1085148793
643342397
1365217451
-415646314
-1874948864
154655930
2117135404
-531334769
-1756149479
240785571
2036148277
-371051100
-1629158094
132928648
1894474782
-292556355
-1719090901
8491153

647
test_files/baseline.No.txt Normal file

@ -0,0 +1,647 @@
-1652918893
-360889083
178826267
2059557012
231041026
-1798555208
2078888969
216949919
-1780009691
-488634957
1918834722
89663668
1751456182
526526752
-2130264957
-167670763
1862852015
403696953
-1268966888
-1017501042
1515420468
1858579957
432053603
-2134258471
-137429937
1772775916
514677114
-2019292992
74506435
1937231957
-360807953
-1652969095
52241626
1947866188
684761840
1607963238
-1045231675
-1229703341
800941801
1488606847
-709731446
-1565168868
1002191526
1287326256
1984339663
-279982219
-1740046365
103574080
1898666710
-400422036
-1624949766
304952847
1697253017
-64792797
-1960548427
356577814
1648870016
-78736582
-1941331028
485932605
1810992811
-218570991
-2046824569
463174180
1792624348
501118538
-2066274320
-204466330
1840546501
447984211
-2084903959
-188886145
1677905646
319159928
-1493355535
-1126250662
-1145896125
-860605483
1438474863
582636281
-1308274840
-989691906
-1322605515
-970091357
1596245273
673445263
-1236836308
-1052749638
1481179392
793653654
-1074713593
-923394927
-472112490
-1797582336
231883706
2060809004
-458103153
-1816734183
180324259
2109257525
-318264668
-1711236558
50973576
1947138846
-362123587
-1653776853
73666449
1935884039
-1399137899
-341064337
-1666386439
94741571
1923257557
-322567818
-1681837600
46686298
1976520908
-445624995
-1837662773
192818289
2088312039
-501380796
-1793410606
202631272
2064963838
-165882613
-2128878179
403878951
1863681201
-244248302
-2039078524
528445502
1752711336
-121152199
-1883214417
382286869
1640893571
-5596896
-2001884746
296024076
1722009754
-68635036
-1930459406
367449928
1658972126
-58363267
-1954397461
311104337
1703683015
-181191082
-2110517568
457006970
1815769068
-228656561
-2057712935
475044707
1800907765
-429939200
-1856465258
139577132
2136405946
-516791783
-1774890353
255591221
2017145763
-393990606
-1618796892
109727518
1905098632
961040115
1313832549
-802427962
-1490232496
1042647786
1227012732
-1003833463
-1288861921
707057317
1562633779
-1018727536
-1270856954
759763644
1515069994
-890159173
-1107947731
620715671
1408790017
-845349982
-1164195020
596810382
1419094552
-1278591182
-993194076
1416761909
594879139
-1166249191
-847559793
1394595372
605611706
-1122912512
-904493162
1465776488
542820862
-1185703868
-833312558
1345338737
657919463
-1103209379
-918983477
1501983066
780222924
-1215819658
-1064361760
1592505667
703366613
-1327115153
-941431559
1256909068
1038997914
-1528526816
-740050762
790622102
658340430
1345997528
-832643205
-1185288211
1902708288
107886294
-1620613268
-396339206
1980023385
17035983
-1744133259
-284322845
2142408306
146128612
1573363707
717270893
-1278607657
-993079743
1521114082
766339956
-1264305458
-1012725160
967587643
-1599773055
-677226985
1237762996
1052898082
-1480023400
-791703026
1081118623
930594569
-1367413069
-646324699
1193102214
807041808
-1458361686
-569107908
2016494602
255227036
-1774246618
-516418128
2136768531
140226693
-1856839361
-430583383
1995099192
32373934
703546416
-1327098486
-941546212
1501933759
780304425
-1215573613
-1064509179
1345584276
657771522
-1103258184
-918901458
1465792653
542705691
-1185916511
-833132233
1045594881
1230353303
-799219155
-1487154501
960448280
1312323470
1979857543
-423811306
-1850075264
145966650
2142533292
-506404081
-1764240487
266240547
2027532981
-170803392
-2099867690
467656300
1826156282
-222528679
-2051322929
481434229
1807035107
-83216526
-1945303068
352605790
1644390088
-60296341
-1956592643
308908615
1701749457
-754413588
-1542471814
1023864512
1241636438
-731558923
-1553826973
980101849
1298930255
-573372450
-1428932792
870147826
1155159652
-625032249
-1380322479
883991275
1136104061
-826302584
-1179078882
548535972
1471598130
-1479648698
1053232124
1237334890
-645978373
981804216
1300370478
597140405
-1163988465
-845561191
1409111866
620390316
-1108134378
-889977216
1514871569
759966599
-1270515139
-1019065685
1562828552
706867102
-1289175516
-1003516238
1227326279
1042330577
-1490427285
-802237699
1313490782
961378248
-1606146446
-683469084
1207700341
821771235
-1443730855
-554345777
466683364
1825977714
-169909048
-2099751842
335144853
1694422787
-34109767
-1963936209
345252748
1670583066
-90553696
-1919061450
1603336139
-963008911
-1315006745
804913988
1492988882
-1040948632
-1225567490
-1900897941
504202490
1762309228
-268180010
-2029726400
425738467
1852272757
-143777329
-2140597927
-2086079387
499933638
1791709520
-205389590
-2067451780
-1992933673
-30339519
1854804944
428417862
-2139065604
-142130582
1622906243
398238997
1456461893
566814931
-1195263639
-809072129
1369578588
648359114
-1079214736
-928297498
1477726327
789799137
-1239797413
-1055063603
1601803374
679388408
-1317538494
-965687852
-1518950131
-764307045
1276447800
991050926
-1575260908
-719561342
1168326675
849637509
-1414717121
-592834135
1120830474
902411420
-1396644570
-607660624
1839331469
447137819
-2085643871
-190273225
1791769748
499846146
-2067636808
-205165266
1668968639
343752745
-1921773165
-93118203
1679275174
319849520
-1978018422
-48306916
1880549609
118610047
-1642559035
-383796909
2004561136
8133734
-1720365604
-294486710
2127388891
164253773
-1866268169
-406572703
2040571074
245863508
-1750153746
-525732488
-934480437
-1085553315
641897703
1363518577
-819908142
-1205468860
556749054
1445486696
-1876641318
154003552
-2140681519
426679147
1852419069
1455844873
-928842838
-1079653572
648845958
1370204688
-1085495143
-934569969
1363331509
642119971
-1205769088
-819569642
1445924268
556285242
-2078111663
-215631673
1781328253
489413099
-2091955128
-196576034
1832988004
440802802
-977274016
1555475162
733059660
-1244327953
-1026408583
1541107395
752639573
-1100097886
-915741132
1460564887
537477889
-1191177541
-838393299
-1176451246
-823658556
1475257982
552179432
-1098054837
-913689635
1350787687
662983409
-1220849824
-1069776906
1496657484
775036634
-1336505479
-950944785
1582885461
694147779
-1537747146
-749672544
1247393306
1029605004
-1556475089
-734190663
1295282691
976437909
-1433641212
-578064494
1149386280
864358078
-1377723619
-622417013
1139800625
1735016478
275607688
-1911954133
-116468291
1611105287
385922193
-2017482496
-256337514
1773258796
515307706
-2133693159
-137011825
1859914805
433798307
-1346563682
-658890488
1102278834
917782564
-1462708857
-539499247
-1897888114
401200948
1626269602
-24481279
-1987231081
277091117
1736647611
-147046870
-2143613252
422731526
1848995728
-263062989
-2024355163
509582111
1767418761
-464476548
-1822976278
173983568
2103048134
-482516379
-1380743944
-625691538
-388317536
-1612870090
28908437
1992174339
-273188167
-1733277137
364398554
1656715084
-71948554
583566737
-1129574350
-877977436
1386377502
631587208
-1815909195
-456893405
168994806
2098567008
-467876134
-1826884020
226452463
2054706041
-479132989
-1804193195
80293828
1942888274
-356036888
-1648329090
61139933
1956895563
-307590415
-1699890585
396736402
1621264132
-1504074264
921090169
1105299695
-655828651
-1343231549
831224928
1183599862
-544924340
-1467863590
-482678759
-1807886193
221546805
2050210211
-464049152
-1823466346
173624620
2103344570
-303996885
-1696182083
65995015
1961374097
-359881678

717
test_files/baseline.P.txt Normal file

@ -0,0 +1,717 @@
-1637089325
123907689
1885708031
-1727644726
1010288
1997036262
-407419017
-1867483167
163128923
-522550418
-1747078152
248832578
2043925204
336475711
1661535913
1684325040
-1528910307
784033777
-1327500718
-942095676
701932520
366298937
-55123444
432288845
-257453704
-116269741
-1709723254
-317685476
-458830537
-473233106
324281719
1736244924
-1387505153
-632592023
1143995594
858311772
-1440637466
-584667792
48188386
-1680467368
-1167921427
1645789703
-82734147
-1954846926
-574053615
1135359666
-1671666068
89470934
-331967773
-1691245963
1877284644
529523627
1753797437
656418399
1344739017
-834436246
-1186679812
-730375818
-2115232820
-152360102
1877113568
417679990
-2038308907
-242815165
1754251001
529043055
-1892183042
-131030168
1631187666
373211716
-2007345177
-10655887
310177024
-2101088111
-171655161
868550359
1153578561
-573872133
-1429448851
883475150
1135604312
-626613278
-1381919884
1025412837
1243201139
-753864759
-1541939361
980634364
1299479146
-729994288
-167232935
1416111855
594482809
1320350354
-802037988
824919640
514032370
1937663513
75060879
-200888513
-2097045591
436784659
1829764741
-38739180
-1967664254
331252280
1689891502
-86169843
-1915086949
349390369
1674868407
-287540414
-1713681452
13769326
-374227109
895988372
1113620994
-603711583
-1425856713
-1321730773
-974051199
-1292494825
738150829
1559787835
-1029903208
-1137864667
623165855
2023006385
261328935
-1846082172
-420465390
2147050664
150885438
461160969
261760619
2023560957
-510376121
-1768720431
150463090
2146489060
-419855522
-1845578808
21081689
-879203649
1602588035
-963847111
-1156428839
628547194
-2066724300
448061335
1840508673
832496016
-1466453974
1457168909
568169115
-1194015967
1600974374
678158000
-1318940918
350116940
1675193562
-87016096
-1915286026
330537045
1689561283
-37881479
-1967470097
436589694
1828906216
-200559278
1858366480
432233606
638118695
1359993777
-715156466
-1571249000
995226914
1280755124
-768454633
-1523228543
1010577723
-612099012
-1400689494
898268432
1116556678
-588654555
-1410406221
1544739707
722856941
-1250853298
-1032433960
1535057762
746074100
-1709309239
-1138148348
-886174574
1378311464
622882238
-283662535
1903375002
108265996
-1619176522
-394632416
-2040110345
-245280159
1966153182
37104968
-1690338062
-331854748
1918687687
89909585
-1672300309
-346716035
-242263040
-1632905517
-374544827
1889908735
128092009
-1715072310
-289332644
2009625574
13583216
-1871683871
-411603337
2122203085
158928731
-1759667464
-535123346
2031352788
236243778
-1200429441
-814360855
1451001683
561756101
-1088478618
-937946384
1360085834
639005660
-1513753061
-758987123
1271633719
1020045217
-1566035454
-709950828
1285968686
1000432568
-1424064983
-602321217
1158684421
840380307
-1401701840
-613119322
1115544348
897248138
-1710753802
-318716064
1946785498
51291724
-361954439
1935954627
73622101
-1797488700
-472166574
2060590824
232074878
-1817068579
-457798837
2109725425
179890791
-2018449518
-256387324
515487272
-2132991093
-136703203
1859338919
433353265
-1989447776
-26452170
1734676108
274873882
-1912165447
-117335249
1611188885
-1032864793
1533471325
-811870072
1452443954
561119625
1450520863
-813932379
-1199878093
1830490583
-200130451
1237647953
1052914375
-1479842947
-791915541
1319683656
967833310
-1599690908
-677275662
1521064455
766421649
-1264059605
-1012872259
1573150238
717450888
1043086502
-1490719460
-1672786476
-347308734
2079547603
217337925
-1778580993
-486919831
2090771658
194614364
-1836005914
-443026064
-641002455
1202684298
816361756
-1449008986
-559493072
1310313889
958332215
-1609061235
-686777317
1232341432
1047738670
-1485150060
-797091838
1567970807
712140129
-1283771173
-998505395
1511559662
757047672
-1273564990
-1022246828
1403968965
1253436548
1035131922
-1531212376
-742605506
1991641173
28391619
678570895
-1317307851
-964932957
1478024960
-1240023508
-1055813958
133444781
-1803322804
-477869350
2056067936
227159030
-1813070251
-454455613
2111889273
182972399
-1705446786
-312491288
1951830866
55681988
-1657457049
-365820175
1933268811
71067613
-1993053656
-30188866
1731857156
272448402
-1906725327
-111239513
1616367389
391184267
-2014322150
-253177204
1776386870
518435744
-2138954237
-142272875
1854687023
428570553
-1343399292
-655726062
1105410984
920914750
-1467965795
-544756213
1183776689
831115047
-1590242634
-701373920
1329116058
943686412
-1503979857
-782490055
1213560707
-1302705440
-983729546
1549020108
726866778
-1254650119
-1036992913
1530523605
742317891
-1132346670
-880348604
1385145342
629707624
-1142159669
-857000355
1440901095
585455473
-1919399155
-90211429
1670785569
-170288106
1825623468
467139898
-1945819982
-83749852
1644905886
353137928
-1956061013
-59781059
1701216647
308392209
-1620460316
-395408270
-1744537347
-284997525
1980373457
17639751
-1850592042
-424344512
2143049210
146498924
-1763708721
-505888679
2027000291
265724277
-1543005140
-625549167
-1954091318
418911847
763480886
1518795680
1906668523
-391372207
-1616178489
-1444978943
-680647748
-319943403
-1679213181
93169696
1921685686
-343684852
-1669006950
539260505
1461929679
-836102283
-1188223005
-736178839
-1558577665
463755504
1822648422
-173393444
482974953
-1607369882
-684307472
-386643427
550311420
-1178319802
-826051376
1353179507
664850917
-1096187809
-911298359
1494330712
773234126
-1222652812
-1072104222
1585211713
695949783
-1379592183
-624809825
-582462293
-1437637571
860239239
1145111825
24139525
1987536787
-576300342
-1432262052
867128866
-242238536
-2037871826
-2115176069
-152319507
1877121111
417704129
-2038350494
-242872844
1754225742
529034456
-1892191927
-131055137
-1165829709
-846862043
1418508447
596346889
-1108402774
-890753732
1407286406
619072528
-1269214847
-1017224937
1515663533
760217659
-1288399464
-1003248370
1564144820
708690978
-2059347874
-230168376
1800321394
474581476
-2110972857
-181785391
1814265195
455364093
-1952755604
-56860422
1704276288
311558614
-1929997195
-68049693
1660482905
369083855
-1728591814
-269420372
1996073238
-1617294301
-392348491
1905552655
110321049
-1775484920
-517246818
2015502628
254087602
-1857977327
-431573881
2135942461
138991019
-1104217962
-920008704
656910636
-1326092124
1593512328
704389406
-1892672371
372854071
1631485345
-2007115628
290752814
1716763064
-152263639
-2115267393
417514757
-243179472
-2038017882
529465628
1753756042
89511265
1918035447
1967071726
-1017574189
1228719423
-682078052
-1604362230
1313931558
1800000694
-2111147645
1814302895
-633193070
-1387983612
877419710
1129016360
-584058485
-1440167651
-395923676
-1620992078
107531784
-1618916773
371549835
275689837
-2092500476
-253065613
-880499013
-704911953
-1560488647
1005945987
1290974229
-761912906
-1517219552
1016610970
1268740108
-618631779
2116737270
-593254427
-1415276685
850249417
1168832095
-607230980
-1396092054
901776080
-365000314
1933039676
70314154
-1705738999
-313307745
1952062501
56437939
-479802420
2054134390
224963296
-1827913917
179807477
-1710704284
-317748750
1946605640
50456798
-1654293123
-362656277
250973105
-1869537774
2124382014
160976808
-1494920236
-773692606
-255855534
-2017934140
514954622
1773577704
-787808025
-1509150607
-1293720993
736768997
1559036787
-867033374
-1152045452
-1137120659
1223450428
-1584399863
948349875
1333893925
1829974657
437518871
-2095230035
-199597253
1786705560
494519822
898986225
88401072
-11750377
1715856813
289592635
-1893318504
-132026354
1630020020
372183330
-2037379917
-241746907
1755213215
530144521
-2114074454
-151324612
1878239622
418683152
-1778608923
-486824845
2079520201
217433439
-1835970308
-443129750
2090807760
194511174
1640995225
-121190365
-1883113291
1154490829
869732699
-1428274975
-91312654
-1920361116
343985374
1669856328
-35427861
269976758
1729147936
-1471926312
151771187
-1716206174
-290196172
2008720526
12424216
-1346336668
-534258619
1977458936
-446513815
-1838838273
191683653
2087447763

@ -0,0 +1,10 @@
701932520
897248138
-1710753802
-2132991093
596346889
-1108402774
-68049693
1660482905
369083855
1313931558

@ -0,0 +1,24 @@
-1747078152
-1680467368
-1167921427
-879203649
-37881479
-1632905517
-374544827
1889908735
128092009
-1715072310
-289332644
391184267
1776386870
1385145342
629707624
-1919399155
-1763708721
-1543005140
-1954091318
-846862043
1418508447
-1775484920
656910636
-2038017882

@ -0,0 +1,73 @@
-1867483167
-942095676
-55123444
1113620994
-1425856713
628547194
1935954627
1533471325
1452443954
1450520863
-1199878093
-200130451
1052914375
-791915541
967833310
-677275662
766421649
-1012872259
717450888
-1490719460
-347308734
217337925
-486919831
194614364
-443026064
1202684298
-1449008986
1310313889
-1609061235
1232341432
-1485150060
1567970807
-1283771173
1511559662
-1273564990
1403968965
1035131922
-742605506
28391619
920914750
-544756213
831115047
-701373920
-83749852
353137928
-59781059
308392209
-395408270
-284997525
17639751
-424344512
146498924
2027000291
265724277
-242238536
-1892191927
1407286406
-1269214847
1515663533
-1288399464
1564144820
-2059347874
1800321394
-2110972857
-1952755604
2015502628
-1857977327
2135942461
-2115267393
-1604362230
-2111147645
-633193070
1129016360

@ -0,0 +1,10 @@
-458830537
-411603337
-535123346
1158684421
227159030
-454455613
1951830866
-365820175
-142272875
-655726062

@ -0,0 +1,12 @@
-116269741
-1871683871
158928731
-1759667464
236243778
-602321217
2056067936
-1813070251
-312491288
-1657457049
-2138954237
-1343399292

513
test_files/baseline.Po.txt Normal file

@ -0,0 +1,513 @@
-1637089325
123907689
1885708031
-1727644726
1010288
1997036262
163128923
-522550418
248832578
2043925204
336475711
1661535913
1684325040
-1528910307
-1327500718
432288845
-257453704
-1709723254
-317685476
-473233106
324281719
1736244924
-1387505153
-632592023
1143995594
858311772
-1440637466
-584667792
48188386
1645789703
-82734147
-1954846926
-574053615
1135359666
-1671666068
89470934
-331967773
-1691245963
1877284644
529523627
1753797437
656418399
1344739017
-834436246
-1186679812
-730375818
-2115232820
-152360102
1877113568
417679990
-2038308907
-242815165
1754251001
529043055
-1892183042
-131030168
1631187666
373211716
-2007345177
-10655887
310177024
-2101088111
-171655161
868550359
1153578561
-573872133
-1429448851
883475150
1135604312
-626613278
-1381919884
1025412837
1243201139
-753864759
-1541939361
980634364
1299479146
-729994288
-167232935
1416111855
594482809
1320350354
-802037988
824919640
514032370
1937663513
75060879
-200888513
-2097045591
436784659
1829764741
-38739180
-1967664254
331252280
1689891502
-86169843
-1915086949
349390369
1674868407
-287540414
-1713681452
13769326
-374227109
-1321730773
-974051199
-1292494825
738150829
1559787835
-1029903208
-1137864667
623165855
2023006385
261328935
-1846082172
-420465390
2147050664
150885438
461160969
261760619
2023560957
-510376121
-1768720431
150463090
2146489060
-419855522
-1845578808
21081689
1602588035
-963847111
-2066724300
448061335
1840508673
832496016
-1466453974
1457168909
568169115
-1194015967
1600974374
678158000
-1318940918
350116940
1675193562
-87016096
-1915286026
330537045
1689561283
-1967470097
436589694
1828906216
-200559278
1858366480
432233606
638118695
1359993777
-715156466
-1571249000
995226914
1280755124
-768454633
-1523228543
1010577723
-612099012
-1400689494
898268432
1116556678
-588654555
-1410406221
1544739707
722856941
-1250853298
-1032433960
1535057762
746074100
-1709309239
-1138148348
-886174574
1378311464
622882238
-283662535
1903375002
108265996
-1619176522
-394632416
-2040110345
-245280159
1966153182
37104968
-1690338062
-331854748
1918687687
89909585
-1672300309
-346716035
-242263040
2009625574
13583216
-1200429441
-814360855
1451001683
561756101
-1088478618
-937946384
1360085834
639005660
-1513753061
-758987123
1271633719
1020045217
-1566035454
-709950828
1285968686
1000432568
-1424064983
840380307
-1401701840
-613119322
1115544348
-318716064
1946785498
51291724
73622101
-1797488700
-472166574
2060590824
232074878
-1817068579
-457798837
2109725425
179890791
-2018449518
-256387324
515487272
-136703203
1859338919
433353265
-1989447776
-26452170
1734676108
274873882
-1912165447
-117335249
1611188885
678570895
-1317307851
-964932957
1478024960
-1240023508
-1055813958
133444781
-1803322804
-477869350
2111889273
182972399
-1705446786
55681988
1933268811
71067613
-1993053656
-30188866
1731857156
272448402
-1906725327
-111239513
1616367389
-2014322150
-253177204
518435744
1854687023
428570553
1329116058
943686412
-1503979857
-782490055
1213560707
-1302705440
-983729546
1549020108
726866778
-1254650119
-1036992913
1530523605
742317891
-1132346670
-880348604
-1142159669
-857000355
1440901095
585455473
-90211429
-170288106
1825623468
467139898
-625549167
418911847
763480886
1518795680
1906668523
-391372207
-1616178489
-1444978943
-680647748
-319943403
-1679213181
93169696
1921685686
-343684852
-1669006950
539260505
1461929679
-836102283
-1188223005
-736178839
-1558577665
463755504
1822648422
-173393444
482974953
-1607369882
-684307472
-386643427
550311420
-1178319802
-826051376
1353179507
664850917
-1096187809
-911298359
1494330712
773234126
-1222652812
-1072104222
1585211713
695949783
-1379592183
-624809825
-582462293
-1437637571
860239239
1145111825
24139525
1987536787
-576300342
-1432262052
867128866
-2115176069
-152319507
1877121111
417704129
-2038350494
-242872844
1754225742
-131055137
-1165829709
-181785391
1814265195
-56860422
1704276288
311558614
-1929997195
-1728591814
-269420372
1996073238
-1617294301
-392348491
1905552655
110321049
138991019
-1104217962
-920008704
-1326092124
1593512328
704389406
-1892672371
372854071
1631485345
-2007115628
290752814
1716763064
417514757
-243179472
529465628
1753756042
89511265
1918035447
1967071726
-1017574189
-682078052
-1387983612
-584058485
-1440167651
-395923676
-1620992078
107531784
-1618916773
371549835
275689837
-2092500476
-253065613
-880499013
-704911953
-1560488647
1005945987
1290974229
-761912906
-1517219552
1016610970
1268740108
-618631779
2116737270
-593254427
-1415276685
850249417
1168832095
-607230980
-1396092054
901776080
-365000314
1933039676
70314154
-1705738999
-313307745
1952062501
56437939
-479802420
2054134390
224963296
-1827913917
179807477
-1710704284
-317748750
1946605640
50456798
-1654293123
-362656277
250973105
-1869537774
2124382014
160976808
-1494920236
-773692606
-255855534
-2017934140
514954622
1773577704
-787808025
-1509150607
-1293720993
736768997
1559036787
-867033374
-1152045452
-1137120659
1223450428
-1584399863
948349875
1333893925
1829974657
437518871
-2095230035
-199597253
1786705560
494519822
898986225
88401072
-11750377
1715856813
289592635
-1893318504
-132026354
1630020020
372183330
-2037379917
-241746907
1755213215
530144521
-2114074454
-151324612
1878239622
418683152
-1778608923
-486824845
2079520201
217433439
-1835970308
-443129750
2090807760
194511174
1640995225
-121190365
-1883113291
1154490829
869732699
-1428274975
-91312654
-1920361116
343985374
1669856328
-35427861
269976758
1729147936
-1471926312
151771187
-1716206174
-290196172
2008720526
12424216
-1346336668
-534258619
1977458936
-446513815
-1838838273
191683653
2087447763

@ -0,0 +1,75 @@
-407419017
784033777
366298937
895988372
-603711583
-1156428839
2122203085
2031352788
-361954439
-1032864793
-811870072
561119625
-813932379
1830490583
1237647953
-1479842947
1319683656
-1599690908
1521064455
-1264059605
1573150238
1043086502
-1672786476
2079547603
-1778580993
2090771658
-1836005914
-641002455
816361756
-559493072
958332215
-686777317
1047738670
-797091838
712140129
-998505395
757047672
-1022246828
1253436548
-1531212376
1991641173
1105410984
-1467965795
1183776689
-1590242634
1670785569
-1945819982
1644905886
-1956061013
1701216647
-1620460316
-1744537347
1980373457
-1850592042
2143049210
-505888679
-2037871826
529034456
-890753732
619072528
-1017224937
760217659
-1003248370
708690978
-230168376
474581476
455364093
-517246818
254087602
-431573881
-152263639
1228719423
1800000694
1814302895
877419710

6799
test_files/baseline.S.txt Normal file

File diff suppressed because it is too large Load Diff

@ -0,0 +1,53 @@
-301921444
-2134022665
-137734815
1773060290
514453588
-339939625
1917978432
-1836388036
-443694678
-346666600
-1489571958
-847142212
560038687
-966410340
-1975220995
-45894549
1682630097
323867975
-1926676252
-97619854
1663508936
337645918
-2069951281
-208126887
1787915747
496393589
-2081240874
-185206720
1845275130
452696428
-1745644391
-520838129
2046686645
251315491
-1868672896
-409378794
2123379116
160891194
-1725424469
-298898371
1999011207
2182417
-1639589710
-381491164
1884010910
814287667
883722583
-940425166
-10819582
-395026672
-1619824762
-1742820449
18348581

121
test_files/baseline.Sk.txt Normal file

@ -0,0 +1,121 @@
1590793086
-1615819051
1612221673
-25421494
1947848870
2108660877
1784807030
493276896
-2096997565
-200971307
2010574354
13753988
-1632285913
-374178895
1891314187
129768093
-1761409268
-536594534
2030921248
235558582
-1871789291
-412486781
2120262201
157782703
-815052003
1449269927
560278065
-1311098976
-958593226
1607751308
684942874
-1045380305
801022467
-1565085706
-709779616
1287179994
1002438220
-1512346641
-757310599
1272253123
1020410453
-1402132540
-613804206
1113802472
895776382
-1426005027
-603466933
1158578929
839496295
-2071528193
-25841914
-1988976752
-1728630910
1996050094
-645639470
-1367121340
-1489686929
1044152277
1228623683
-1165869557
596340657
1418485543
-1671754073
89284381
1918201739
-2115232061
417681273
982321134
-1528196531
1803078226
478149316
-2055820418
-227435544
1813319243
454180573
-2112131225
-182689807
1705198176
312767222
-1951587508
-55962662
1657702009
365541103
-1933514923
-70789181
1993333302
29944480
-1732134118
-272200820
1906449967
111488697
-1616085245
1343679130
655481356
546443380
-1181007410
658506764
1209273672
1058225630
-1585993603
-697263893
1333381457
947845575
-1463688106
-540617536
1188005242
835237356
-1347674033
-659877671
1101152611
916812277
-1713869431
-287351521
961950128
-517202598
1904021162
-1312433930
799100245
1487306179
-1045484423
-1230496529

948
test_files/baseline.Sm.txt Normal file

@ -0,0 +1,948 @@
2126386893
-43150582
-1972722788
325317158
-1951280486
1707062198
1735739632
74654761
-815427435
-200560547
800706503
216235005
2078559083
-346335494
-1653984273
1774094014
1544236612
722214610
-1251439759
1375685931
653819325
-1197676514
-199451675
-26529038
-1989410204
275076062
1734501192
-116984085
1773792122
-923700907
-1074380349
654250105
1375215855
-811813556
673486923
1596172509
-299351559
1998655555
122414284
160460030
736460151
1558334945
1071915320
-695761907
-303455035
-1695640493
65521129
1960899967
-463476498
-1822893960
173115842
2102835540
-483250953
-1808458655
222055899
2050719053
1271221439
1019378729
-1513411181
-758375163
1286113446
1001371696
-1566119542
-710813412
1159644301
840561691
-1424972383
-602434249
1114833044
896806914
-1401069128
-612740818
1450335451
561343565
-1199817225
-814019231
1361025218
639150164
-1089340946
-938030728
1487525097
799990911
-1230522939
-1046444717
1606684912
683876454
-1312132644
-959626934
1890282615
128736481
-1633350309
-375243315
2009507950
12687608
-1714894526
-288359980
2121327685
158848211
-1870756503
-411453953
2031951964
236589258
-1760345744
-535531034
1830583315
437996677
-2095964865
-199938647
1785837578
494307484
-2071996122
-210179664
1674048545
348177591
-1916168947
-87120485
1688875064
330105006
-1968942828
-39624318
1390312958
634998120
-1127211822
-875090876
1437841895
582257009
-1145186101
-860166051
1543894476
721601882
-1307863840
-989027210
1533555157
745472323
-1251585799
-1033805713
1332309402
946756876
-1587082058
-698336224
1208265091
1057200405
-1509242705
-787613639
1102243240
917886270
-1346599804
-658787310
1189028273
836243751
-1462681443
-539594741
1773165878
515337632
-2017575910
-256308084
1860016431
433760697
-2133592061
-137049963
1735120132
275572114
-1989823448
-27097922
1611010333
385950091
-1912049615
-116440921
1946635602
50363844
-1710674818
-317842200
1936361803
74299869
-1654331289
-362555151
2061288800
232519158
-1798134708
-472541990
2108752249
179712495
-1816174507
-457682749
2045980221
250879659
-1745006831
-520454265
2124343844
161077938
-1869575416
-409486434
1999152655
3118745
-1725511901
-299763787
1883595286
121787008
-1639251142
-380882004
1682194009
323161807
-1974837387
-45256733
1663695424
338610902
-1926784148
-98522118
1788851819
496535293
-2070816953
-208214063
1844605554
452281060
-2080631970
-184867896
1117589237
899300963
-1399623719
-611033265
1173408492
855112314
-1409373248
-587621546
1279690439
994162257
-1572280341
-716187779
1261126366
1009545800
-1524292622
-769518748
1596595857
674049543
-1323008067
-970764501
1481104008
792783390
-1236681820
-1051817166
1374787235
653698613
-1073743985
-923220199
1453085370
563831340
-1198378090
-812317952
1625825148
401551338
-1897497008
-102674746
1736825701
277015539
-1987331511
-24343841
1848874830
422881240
-2143422878
-147142924
1767789399
509174721
-2024787333
-262733075
2103381784
173555598
-1823379916
-464101726
2050149121
221641623
-1807963603
-482633029
1938065194
75741116
-1651841530
-359803248
1961444147
65958821
-1696128481
-304082295
1535524788
746655522
-1249354088
-1030787570
1558969261
736938811
-1293575551
-975001065
1432205190
576358160
-1152133462
-866851268
1378907039
624378633
-1136782669
-885448155
1177628624
825630534
-1472246020
-549945750
1096608713
911989599
-1353544987
-665470349
1223337954
1072535412
-1494956338
-773589416
1334273019
947934061
-1584856361
-695324095
348629363
1673566693
433964157
-1745214763
161396598
2123991008
-409938342
-1869093172
653380593
1375140711
-922768675
-1074226613
563875816
1453014910
-812486972
-1198170542
673858499
1596814165
-970710289
-1323101575
793216986
1480636236
-1052121354
-1236347296
994499477
1279388419
-716653895
-1571845585
277186103
1736619681
-24385765
-1987258483
1072364208
1223543334
658101871
-241667401
-1365378369
-644167127
1083415443
932489989
-1443873114
-554234320
1207852938
821653276
-1278389514
1313261609
960624831
-1605850875
-682649197
1227557936
-803054198
1084047387
932868237
-1366089417
-644607583
1206944770
821539988
-1442912978
-554052168
1408358477
620161243
-1107314335
-889681417
1419517012
597372098
-1164804744
-845853202
1563054207
707617001
-1289473709
-1004338747
1514640486
759211248
-1270221494
-1018247716
1965615329
36690039
-1691973171
-333334181
1917136120
88218734
1755314309
530106387
-2037278295
-241784513
1878146204
418712586
-2114167376
-151294682
1715761335
289620001
-2008411749
-11722483
1630123182
372147256
-1893214846
-132061932
1928603409
99817351
-1661319619
-335710549
1973019400
43963294
-1684569564
-326061390
2083499811
187211701
-1843278321
-450429287
2067950394
205872044
-1790178794
-498386304
1866676085
407111651
-2125638055
-162896177
1747907436
522830842
-2044685760
-249060650
1637400391
379555793
-1885938069
-124653827
1727363934
301091784
-1996809614
-251164
1234831321
1050490703
-1483446539
-795650461
1324860352
972092246
-1594252564
-671182214
1195479019
809942909
-1454379321
-565649839
1076644850
925596516
-1373492514
-651879864
1412241341
589965099
-1172081007
-853260793
1396757412
608690994
-1118915960
-901152226
1526112143
770813721
-1258750301
-1006645707
1570462614
714894080
-1282065734
-997062100
1810830928
484976326
-2048821380
-219789334
1820512841
461759199
-2104708251
-175406093
1697947234
305377012
-1959067826
-63057960
1650023035
358509293
-1940440233
-78640191
1985480244
23017122
-1739167976
-279881842
1899348525
104002235
-1623481599
-398683241
2021887494
260357776
-1769083094
-510992452
2146322975
149518985
-1847579853
-421061723
1350645400
663094798
-1097902156
-913807582
1475146369
552321559
-1176333395
-823811269
1583005354
693997116
-1336615034
-950800624
1496808115
774916645
-1220994145
-1069667575
1295394556
976295530
-1556592688
-734038202
1247535845
1029493363
-1537899575
-749554849
1139650254
887791192
-1377579038
-622526604
1149266647
864508481
-1433531397
-578208915
1086473619
935687429
-1362352961
615116115
-1113539351
-894989185
1422072284
600058186
-1160939280
-842381210
2074895707
212555213
-1784544137
-492489503
2093064514
197562836
-1831878546
-439815944
1970793833
40951295
-1686533051
-327238445
1914317168
85793254
-1676392356
-351045430
1713075519
287065513
-2011884525
-15588219
1635168550
376537520
-1887907830
-125837156
1757478157
533187995
-2033279967
-238441289
1873623316
413796738
-2120001480
-156997458
1507423442
786318404
-1210640898
-1060100760
1588900043
699629661
-1329933849
-943857295
1459813600
537250934
-1190355508
-838095526
1349466361
661129327
-1100916267
-916035261
1148085430
862540832
-1436547686
-580438772
1124311215
872714297
-1391607421
-636817131
1306011805
987699211
-1546237519
-724469465
1656181786
363881612
-1934019274
-71432800
1708822531
316514453
-1948978897
-53231175
1819073576
460057790
-2107458300
-177893998
1795233841
470165671
-2062583523
-234337909
2130723966
134706408
-1861343918
-435612220
2020442215
258650353
-1771839157
-513486371
1910230092
115145946
-1613386400
-388850186
-1732744839
-272672273
-566138851
-1455007605
810486065
1195915687
-651383804
-1372873582
925027624
1076231614
-795156433
-1482829639
1049919747
1234416021
-671669194
-1594878816
972637466
1325299084
-1007257479
-1259255569
771234133
1526671811
-996426656
-1281585930
714464588
1569910234
-852627381
-1171603235
589533543
1411686897
-901761966
-1119419196
609113470
1397319144
-449885995
-1842841533
186722809
2082871663
-498955060
-1790591910
206368224
2068569462
-336281369
-1661734799
100311499
1929220445
-325516034
-1684130712
43476434
1972393284
-124233551
-1885378521
378943901
1636894987
-680792
-1997362114
301727108
1727843602
-163327869
-2126192619
407744943
1867153721
-248638310
-2044124148
522220982
1747404064
-950380196
-1336055350
693385328
1582500070
-1070097083
-1221546541
775552105
1497287935
-914239122
-1098456584
663728194
1351123156
-823388809
-1175771679
551711835
1474643149
-621983432
-1377142354
887302164
1139021954
-578777823
-1433944649
865004557
1149885595
-734609142
-1557007972
976789542
1296011440
-749009645
-1537460859
1029006399
1246909609
-63669868
-1959573246
305797304
1698506798
-78004851
-1939960549
358079649
1649470519
-219156058
-2048343760
484544650
1810276380
-176015937
-2105211607
462181523
1821074437
-511481360
-1769711258
260901084
2022324298
-420565527
-1846960769
148950213
2145909843
-279387710
-1738550956
22446318
1985065080
-399170085
-1624107699
104547575
1899787361
-327742817
-1687143927
41511859
1971215141
-350564730
-1675756016
85241770
1913888572
-492010835
-1783909829
212001665
2074465047
-440318284
-1832487390
198125464
2093487886
-239068421
-2033767827
533625815
1758022465
-156377374
-2119504268
413384654
1873055576
-14970167
-2011389345
286651365
1712505715
-126462256
-1888393658
376977404
1635714922
-686216617
-1608639807
957827963
1309703149
-797643186
-1485578536
1048219490
1232977908
-641555867
-1362783501
936166217
1087108063
-558930308
-1448585494
815859536
1202075590
-894551501
-1112995163
614488863
1403480969
-842793430
-1161507140
600678150
1422569360
-998919679
-1284341097
712758061
1568465851
-1021807080
-1273018738
756422452
1511073698
-177456162
-2106913976
459430642
1818585700
-234750009
-2063151279
470785771
1795731069
-71846932
-1934589062
364499648
1656676950
-52791307
-1948432541
315889369
1708336719
-388289606
-1612965076
114641558
1909619200
-273223773
-1733173451
28872335
1992277529
-436165752
-1861774562
135185060
2131358258
-512923759
-1771415801
258148029
2019833387
-838722794
-1190843520
537688634
1460357804
-915415281
-1100419175
660717091
1348898485
-1059482844
-1210145870
785904136
1506853534
-944482499
-1330419797
700069393
1589446279
-743109774
-1531823132
1035692638
1253857992
-723988629
-1545601027
987147847
1305583313
-579960000
-1435913258
861987436
1147654906
-637319335
-1392216113
873277045
1124734691
-1661690443
-336351965
1929051289
100518927
-1684448852
-325162694
1972844672
42993686
-1842408057
-450353903
2082567339
187057213
-1790783074
-498736888
2068623538
206274596
-1556702120
-734942002
1295580532
977260002
-1537517503
1028786683
-1376971670
-622189316
1138980166
887375312
-1434398605
-263739866
1344313786
-1186775921
-834401255
1464688035
1877341587
-331976620
-1691270974
37228920
-181583595
455286841
108674620
-1851201612
144815630
2141619864
-507374789
1524826751
-1484653819
-1662002227
259539141
873881613
-352220930
-797988810
693075464
304176832
-796809641
-1660970818
-336025560

5677
test_files/baseline.So.txt Normal file

File diff suppressed because it is too large Load Diff

19
test_files/baseline.Z.txt Normal file

@ -0,0 +1,19 @@
-378745019
1858274523
829915701
-2095266121
-199494111
1829939099
437622541
-2072968530
-210357704
1786733442
494424852
-1916318075
-88048109
1674129321
-1230410163
-1045537061
684588014
386923011
-2099336064

Some files were not shown because too many files have changed in this diff Show More