Comparing version
@@ -5,2 +5,14 @@ # Changelog | ||
### [0.0.4](https://github.com/Anadian/cno-base64/compare/v0.0.3...v0.0.4) (2024-03-31) | ||
### Tests | ||
* Redid test to use `cno-test` ([821064f](https://github.com/Anadian/cno-base64/commit/821064f81ea313b29dadff3df88afb6dead80960)) | ||
### Documentation | ||
* Updated README. ([928a964](https://github.com/Anadian/cno-base64/commit/928a964f6bf7f80a4158f2674f6c7da87b64f00b)) | ||
### [0.0.3](https://github.com/Anadian/cno-base64/compare/v0.0.2...v0.0.3) (2024-03-31) | ||
@@ -7,0 +19,0 @@ |
{ | ||
"name": "cno-base64", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Micropackage: convert between a NodeJS Buffer and a base64-encoded string with optional URL-safe alphabet, padding, and MultiBase prefix.", | ||
@@ -93,2 +93,3 @@ "repository": { | ||
"c8": "^9.1.0", | ||
"cno-test": "^0.0.1", | ||
"eslint": "^8.57.0", | ||
@@ -95,0 +96,0 @@ "extract-documentation-comments": "^0.4.2", |
@@ -20,3 +20,13 @@ # cno-base64 | ||
# Install | ||
Available on the [npm registry](https://www.npmjs.com/package/cno-base64) as `cno-base64`. | ||
Adding it to project using [pnpm](https://pnpm.io/cli/add): | ||
```sh | ||
pnpm add --save cno-base64 | ||
``` | ||
It can, of course, also be installed by [npm](https://docs.npmjs.com/cli/v8/commands/npm-install) or [yarn](https://yarnpkg.com/getting-started/usage) using the normal methods. | ||
# Usage | ||
```js | ||
import Base64NS from 'cno-base64'; // Default export is a full "namespace". | ||
import { getBase64FromBuffer, getBufferFromBase64 } from 'cno-base64'; // Just the functions. | ||
``` | ||
# API | ||
@@ -23,0 +33,0 @@ # Contributing |
@@ -37,5 +37,4 @@ #!/usr/bin/env node | ||
//## Standard | ||
import Test from 'node:test'; | ||
import Assert from 'node:assert/strict'; | ||
//## External | ||
import Test from 'cno-test'; | ||
//# Constants | ||
@@ -48,23 +47,4 @@ const FILENAME = 'lib.test.js'; | ||
/**## Functions*/ | ||
function errorExpected( expected, received ){ | ||
//console.error( "%o", received ); | ||
if( received instanceof expected.instanceOf ){ | ||
if( received.code === expected.code ){ | ||
return true; | ||
} | ||
} | ||
return Assert.fail(`received: ${received}\nexpected:${expected}\n`); | ||
} | ||
/*Test( 'FullTest', function( t ){ | ||
Test.test( 'getBase64FromBuffer:throws', function( t ){ | ||
t.diagnostic( t.name ); | ||
const expected = ( error ) => { | ||
instanceOf: TypeError, | ||
code: 'ERR_INVALID_ARG_TYPE' | ||
}; | ||
const input_function = LoggerNS.initLogger.bind( null, 0 ); | ||
const validator_function = errorExpected.bind( null, expected ); | ||
Assert.throws( input_function, validator_function ); | ||
} );*/ | ||
Test( 'getBase64FromBuffer:throws', function( t ){ | ||
t.diagnostic( t.name ); | ||
const test_matrix = { | ||
@@ -113,8 +93,8 @@ functions: { | ||
var bound_function = input_function.bind( null, ...condition.args ); | ||
var validator_function = errorExpected.bind( null, condition.expected ); | ||
Assert.throws( bound_function, validator_function ); | ||
var validator_function = Test.errorExpected.bind( null, condition.expected ); | ||
Test.assert.throws( bound_function, validator_function ); | ||
} | ||
} | ||
} ); | ||
Test( 'getBase64FromBuffer:returns', function( t ){ | ||
Test.test( 'getBase64FromBuffer:returns', function( t ){ | ||
t.diagnostic( t.name ); | ||
@@ -203,8 +183,8 @@ var test_matrix = { | ||
var function_return = input_function.apply( null, condition.args ); | ||
//var validator_function = errorExpected.bind( null, condition.expected ); | ||
Assert.deepStrictEqual( function_return, condition.expected ); | ||
//var validator_function = Test.errorExpected.bind( null, condition.expected ); | ||
Test.assert.deepStrictEqual( function_return, condition.expected ); | ||
} | ||
} | ||
} ); | ||
Test( 'getBufferFromBase64:throws', function( t ){ | ||
Test.test( 'getBufferFromBase64:throws', function( t ){ | ||
t.diagnostic( t.name ); | ||
@@ -254,8 +234,8 @@ const test_matrix = { | ||
var bound_function = input_function.bind( null, ...condition.args ); | ||
var validator_function = errorExpected.bind( null, condition.expected ); | ||
Assert.throws( bound_function, validator_function ); | ||
var validator_function = Test.errorExpected.bind( null, condition.expected ); | ||
Test.assert.throws( bound_function, validator_function ); | ||
} | ||
} | ||
} ); | ||
Test( 'getBufferFromBase64:returns', function( t ){ | ||
Test.test( 'getBufferFromBase64:returns', function( t ){ | ||
t.diagnostic( t.name ); | ||
@@ -323,4 +303,4 @@ var test_matrix = { | ||
var function_return = input_function.apply( null, condition.args ); | ||
//var validator_function = errorExpected.bind( null, condition.expected ); | ||
Assert.deepStrictEqual( function_return, condition.expected ); | ||
//var validator_function = Test.errorExpected.bind( null, condition.expected ); | ||
Test.assert.deepStrictEqual( function_return, condition.expected ); | ||
} | ||
@@ -327,0 +307,0 @@ } |
27342
1.3%40
33.33%7
16.67%508
-3.79%