Skip to content

Commit

Permalink
improve JSON.stringify (#17)
Browse files Browse the repository at this point in the history
- BREAKING CHANGE - previously it just serialized the properties (no getters).
- BREAKING CHANGE - remove deprecated `parse` method
- bump to v2.0.0
- also update dependencies
- also bump deprecated actions
  • Loading branch information
irahopkinson authored Jun 26, 2024
1 parent 3bc5fbd commit 209054a
Show file tree
Hide file tree
Showing 10 changed files with 1,454 additions and 1,147 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
- run: npm ci
Expand All @@ -35,12 +35,12 @@ jobs:
- run: npm run build
- run: npm run test:ci
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: npm publish
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.') }}
uses: JS-DevTools/npm-publish@v2
uses: JS-DevTools/npm-publish@v3
with:
access: public
token: ${{ secrets.NPM_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -65,7 +65,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -78,7 +78,7 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: '/language:${{matrix.language}}'

Expand Down
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ verseRef = new VerseRef();
`VerseRef` can be used to validate a reference, such as with user form validation:

```typescript
import { ScrVers, VerseRef } from '@sillsdev/scripture';

function isVerseReferenceValid(verseStr: string): boolean {
const { verseRef } = VerseRef.tryParse(verseStr);
return verseRef.valid;
Expand All @@ -84,6 +82,27 @@ console.log(isVerseReferenceValid('GEN 2:3')); // true
console.log(isVerseReferenceValid('LUK 3:4b-5a')); // true
```

`VerseRef` can be JSON stringified and deserialized:

```ts
let verseRef = new VerseRef('LUK', '3', '4b-5a');
console.log(JSON.stringify(verseRef)); // '{"book":"LUK","chapterNum":3,"verseNum":4,"verse":"4b-5a","versificationStr":"English"}'

verseRef = new VerseRef(1, 2, 3, ScrVers.Septuagint);
console.log(JSON.stringify(verseRef)); // '{"book":"GEN","chapterNum":2,"verseNum":3,"versificationStr":"Septuagint"}'

verseRef = VerseRef.fromJSON({
book: 'LUK',
chapterNum: 3,
verseNum: 4,
verse: '4b-5a',
versificationStr: 'English',
});
console.log(verseRef.book); // 'LUK'
console.log(verseRef.chapterNum); // 3
console.log(verseRef.verse); // '4b-5a'
```

Useful properties:

- `book: string` - 3-letter book ID (abbreviation in capital letters), e.g. `'LUK'`
Expand Down Expand Up @@ -158,7 +177,7 @@ console.log(Canon.isObsolete(87)); // true

## Future

v2 might include a more complete port of the C# such that it can be used in a node-based backend.
v3 might include a more complete port of the C# such that it can be used in a node-based backend.

## Contributing

Expand Down
Loading

0 comments on commit 209054a

Please sign in to comment.