Skip to content

Commit

Permalink
Merge pull request #48 from simple-ssi/jrayback_240605_misc-cleanup
Browse files Browse the repository at this point in the history
made small improvements on latest release
  • Loading branch information
jrayback authored Jun 6, 2024
2 parents aff5fad + 1cdfbaa commit 0249aba
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,9 @@ Run all tests, format the code, transpile for ECMAScript and CommonJS, and write
```bash
npm run full-build
```

Three files that serve as a good starting point for developers becoming familiar with the project.

`src/api/encode/text.ts`
`src/api/transform/transformers/transformTextToRaw.ts`
`src/implementation/make.ts`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@simple-ssi/simple-cesr",
"version": "0.2.2",
"version": "0.2.3",
"description": "A simple, limited, true-to-spec implementation of the CESR protocol.",
"type": "module",
"access": "public",
Expand Down
10 changes: 5 additions & 5 deletions src/api/transform/steps/readCodeFromText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const readTwoCharCode = (text: Text): Code => text.substring(0, 2) as Code
const readFourCharCode = (text: Text): Code => text.substring(0, 4) as Code

// reads the code characters from the Text
export const readCodeFromText = (textDomain: Text): Code => {
const selector = textDomain[0] as Selector
export const readCodeFromText = (text: Text): Code => {
const selector = text[0] as Selector
return selector !== '0' && selector !== '1'
? readOneCharCode(textDomain)
? readOneCharCode(text)
: selector === '0'
? readTwoCharCode(textDomain)
? readTwoCharCode(text)
: selector === '1'
? readFourCharCode(textDomain)
? readFourCharCode(text)
: exhaustive(selector)
}
8 changes: 7 additions & 1 deletion src/lib/util/exhaustive.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// TypeScript exhaustiveness check
// see https://www.typescriptlang.org/docs/handbook/2/narrowing.html#exhaustiveness-checking
export const exhaustive = (x: never): never => {
throw new Error("Didn't expect to get here")
throw new ExhuastivenessCheckFailure()
}
export class ExhuastivenessCheckFailure extends Error {
constructor () {
super('Exhaustiveness check failed. Should not have been able to get here.')
this.name = 'EXHAUSTIVENESS_CHECK_FAILURE'
}
}

0 comments on commit 0249aba

Please sign in to comment.