mirror of https://github.com/qntm/base65536
Compare commits
3 Commits
a16b9b6d87
...
8afdaed854
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | 8afdaed854 | |
dependabot[bot] | fbaa931015 | |
qntm | 71a1a16836 |
|
@ -3,3 +3,10 @@ node_js:
|
||||||
- 10
|
- 10
|
||||||
- 12
|
- 12
|
||||||
- 14
|
- 14
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- ~/.cache
|
||||||
|
script:
|
||||||
|
- npm run test
|
||||||
|
- npm run build
|
||||||
|
- npm run test-built
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"fixturesFolder": false,
|
||||||
|
"integrationFolder": "test-built",
|
||||||
|
"pluginsFile": false,
|
||||||
|
"screenshotOnRunFailure": false,
|
||||||
|
"supportFile": false,
|
||||||
|
"video": false
|
||||||
|
}
|
16
package.json
16
package.json
|
@ -11,10 +11,14 @@
|
||||||
"main": "dist/cjs/base65536.js",
|
"main": "dist/cjs/base65536.js",
|
||||||
"types": "typings/index.d.ts",
|
"types": "typings/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"build": "rollup -c rollup.config.js",
|
||||||
"jest": "jest",
|
"jest": "jest",
|
||||||
"rollup": "rollup",
|
|
||||||
"standard": "standard",
|
"standard": "standard",
|
||||||
"test": "standard && jest"
|
"test": "standard && jest",
|
||||||
|
"test-built": "npm run test-built-cjs && npm run test-built-es6 && npm run test-built-iife",
|
||||||
|
"test-built-cjs": "node test-built/cjs.js",
|
||||||
|
"test-built-es6": "babel-node test-built/es6.js",
|
||||||
|
"test-built-iife": "start-server-and-test \"node test-built/server.js\" http://localhost:3000/test-built/index.html \"cypress run --spec test-built/iife.js\""
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"base64",
|
"base64",
|
||||||
|
@ -28,13 +32,17 @@
|
||||||
"author": "qntm",
|
"author": "qntm",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/node": "^7.10.5",
|
||||||
"@babel/preset-env": "^7.8.4",
|
"@babel/preset-env": "^7.8.4",
|
||||||
"base65536-test": "^1.1.2",
|
"base65536-test": "^1.1.2",
|
||||||
|
"cypress": "^4.12.1",
|
||||||
|
"express": "^4.17.1",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"jest": "^26.4.0",
|
"jest": "^26.4.0",
|
||||||
"rollup": "^1.31.0",
|
"rollup": "^2.26.3",
|
||||||
"safe-code-point": "^1.0.0",
|
"safe-code-point": "^1.0.0",
|
||||||
"standard": "^14.3.3"
|
"standard": "^14.3.3",
|
||||||
|
"start-server-and-test": "^1.11.3"
|
||||||
},
|
},
|
||||||
"babel": {
|
"babel": {
|
||||||
"presets": [
|
"presets": [
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
const { encode, decode } = require('..')
|
||||||
|
|
||||||
|
const before = [1, 2, 3]
|
||||||
|
const after = Array.from(decode(encode(Uint8Array.from(before))))
|
||||||
|
|
||||||
|
if (JSON.stringify(after) !== JSON.stringify(before)) {
|
||||||
|
throw Error()
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
// I want to write '..' here, but I can't figure out a way to get Babel to
|
||||||
|
// follow `package.json`'s "module" property instead of its "main" property
|
||||||
|
import { encode, decode } from '../dist/es6/base65536'
|
||||||
|
|
||||||
|
const before = [1, 2, 3]
|
||||||
|
const after = Array.from(decode(encode(Uint8Array.from(before))))
|
||||||
|
|
||||||
|
if (JSON.stringify(after) !== JSON.stringify(before)) {
|
||||||
|
throw Error()
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
/* global describe, it, cy */
|
||||||
|
|
||||||
|
describe('base65536 IIFE', () => {
|
||||||
|
it('works', () => {
|
||||||
|
cy.visit('http://localhost:3000/test-built/index.html')
|
||||||
|
cy.contains('what the heck is up')
|
||||||
|
})
|
||||||
|
})
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
<script crossorigin src="../dist/iife/base65536.js"></script>
|
||||||
|
<script>
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
const encoded = base65536.encode(new TextEncoder('utf-8').encode('what the heck is up'))
|
||||||
|
const decoded = new TextDecoder('utf-8').decode(base65536.decode(encoded))
|
||||||
|
document.querySelector('.root').appendChild(document.createTextNode(decoded))
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="root"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,6 @@
|
||||||
|
const express = require('express')
|
||||||
|
const app = express()
|
||||||
|
app.use(express.static('.'))
|
||||||
|
app.listen(3000, () => {
|
||||||
|
console.log('listening')
|
||||||
|
})
|
Loading…
Reference in New Issue