Skip to content

Commit

Permalink
Modified destructuring style
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 9, 2023
1 parent 01ba4c7 commit fe0a131
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on: push

jobs:
test:
name: Lint, build, and test on node 14.x and ubuntu-latest
name: Lint, build, and test on node 20.x and ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 20.x
- name: Install deps (with cache)
uses: bahmutov/npm-install@v1
- name: Lint codebase
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ as it performs more validity checks than using `set()`.
* `raFile` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)** An ra file, either as a single
string or an array of strings with one stanza per entry. Supports both LF
and CRLF line terminators. (optional, default `[]`)
* `options` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{checkIndent:true,skipValidation:false}`)
* `options` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;

* `options.checkIndent` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \[true] - Check if a the stanzas within
the file are indented consistently and keep track of the indentation
Expand Down Expand Up @@ -268,7 +268,7 @@ than using `set()`.
* `stanza` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)** An ra file stanza, either as a
string or a array of strings with one line per entry. Supports both LF and
CRLF line terminators. (optional, default `[]`)
* `options` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{checkIndent:true,skipValidation:false}`)
* `options` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;

* `options.checkIndent` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \[true] - Check if a stanza is indented
consistently and keep track of the indentation
Expand Down
9 changes: 3 additions & 6 deletions src/raFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ export default class RaFile extends Map<string, RaStanza> {

constructor(
raFile: string | string[] = [],
options: { checkIndent?: boolean; skipValidation?: boolean } = {
checkIndent: true,
skipValidation: false,
},
options?: { checkIndent?: boolean; skipValidation?: boolean },
) {
super()
const { checkIndent } = options
const { checkIndent = true, skipValidation = false } = options || {}
this._checkIndent = !!checkIndent
let stanzas: string[]
if (typeof raFile === 'string') {
Expand All @@ -51,7 +48,7 @@ export default class RaFile extends Map<string, RaStanza> {
this.add(stanza)
})

if (!options.skipValidation) {
if (!skipValidation) {
this.validate()
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/raStanza.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,10 @@ export default class RaStanza extends Map<string, string> {

constructor(
stanza: string | string[] = [],
options: { checkIndent?: boolean; skipValidation?: boolean } = {
checkIndent: true,
skipValidation: false,
},
options?: { checkIndent?: boolean; skipValidation?: boolean },
) {
super()
const { checkIndent } = options
const { checkIndent = true, skipValidation = false } = options || {}
this._checkIndent = !!checkIndent
let stanzaLines: string[]
if (typeof stanza === 'string') {
Expand All @@ -66,7 +63,7 @@ export default class RaStanza extends Map<string, string> {
this.add(line)
})

if (!options.skipValidation) {
if (!skipValidation) {
this.validate()
}
}
Expand Down

0 comments on commit fe0a131

Please sign in to comment.