Skip to content

Commit 209054a

Browse files
authored
improve JSON.stringify (#17)
- 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
1 parent 3bc5fbd commit 209054a

File tree

10 files changed

+1454
-1147
lines changed

10 files changed

+1454
-1147
lines changed

.github/workflows/ci-test-publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
runs-on: ubuntu-latest
2525

2626
steps:
27-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
2828
- name: Setup Node.js
29-
uses: actions/setup-node@v3
29+
uses: actions/setup-node@v4
3030
with:
3131
node-version: 16
3232
- run: npm ci
@@ -35,12 +35,12 @@ jobs:
3535
- run: npm run build
3636
- run: npm run test:ci
3737
- name: Upload coverage reports to Codecov
38-
uses: codecov/codecov-action@v3
38+
uses: codecov/codecov-action@v4
3939
with:
4040
token: ${{ secrets.CODECOV_TOKEN }}
4141
- name: npm publish
4242
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.') }}
43-
uses: JS-DevTools/npm-publish@v2
43+
uses: JS-DevTools/npm-publish@v3
4444
with:
4545
access: public
4646
token: ${{ secrets.NPM_TOKEN }}

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ jobs:
4848

4949
steps:
5050
- name: Checkout repository
51-
uses: actions/checkout@v3
51+
uses: actions/checkout@v4
5252

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

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

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

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ verseRef = new VerseRef();
7272
`VerseRef` can be used to validate a reference, such as with user form validation:
7373

7474
```typescript
75-
import { ScrVers, VerseRef } from '@sillsdev/scripture';
76-
7775
function isVerseReferenceValid(verseStr: string): boolean {
7876
const { verseRef } = VerseRef.tryParse(verseStr);
7977
return verseRef.valid;
@@ -84,6 +82,27 @@ console.log(isVerseReferenceValid('GEN 2:3')); // true
8482
console.log(isVerseReferenceValid('LUK 3:4b-5a')); // true
8583
```
8684

85+
`VerseRef` can be JSON stringified and deserialized:
86+
87+
```ts
88+
let verseRef = new VerseRef('LUK', '3', '4b-5a');
89+
console.log(JSON.stringify(verseRef)); // '{"book":"LUK","chapterNum":3,"verseNum":4,"verse":"4b-5a","versificationStr":"English"}'
90+
91+
verseRef = new VerseRef(1, 2, 3, ScrVers.Septuagint);
92+
console.log(JSON.stringify(verseRef)); // '{"book":"GEN","chapterNum":2,"verseNum":3,"versificationStr":"Septuagint"}'
93+
94+
verseRef = VerseRef.fromJSON({
95+
book: 'LUK',
96+
chapterNum: 3,
97+
verseNum: 4,
98+
verse: '4b-5a',
99+
versificationStr: 'English',
100+
});
101+
console.log(verseRef.book); // 'LUK'
102+
console.log(verseRef.chapterNum); // 3
103+
console.log(verseRef.verse); // '4b-5a'
104+
```
105+
87106
Useful properties:
88107

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

159178
## Future
160179

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

163182
## Contributing
164183

0 commit comments

Comments
 (0)