-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- feat(set): add 'default' mode.
- Loading branch information
Showing
9 changed files
with
162 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
engines: | ||
eslint: | ||
enabled: true | ||
channel: 'eslint-8' | ||
config: | ||
config: '.eslintrc.yaml' | ||
|
||
checks: | ||
method-complexity: | ||
config: | ||
threshold: 10 | ||
|
||
ratings: | ||
paths: | ||
- '**.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule .release
updated
7 files
+3 −0 | CHANGELOG.md | |
+4 −3 | README.md | |
+8 −0 | base.sh | |
+82 −0 | contributors.js | |
+1 −1 | finish.sh | |
+36 −5 | start.sh | |
+29 −17 | submit.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Contributors | ||
|
||
This handcrafted artisinal software is brought to you by: | ||
|
||
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-notes/commits?author=msimerson">23</a>)| | ||
| :---: | | ||
|
||
<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,58 @@ | ||
class Notes { | ||
constructor(notes) { | ||
if (notes && typeof notes === 'object') { | ||
Object.assign(this, notes) | ||
} | ||
|
||
Object.defineProperty(this, 'set', { | ||
configurable: false, | ||
enumerable: false, | ||
writable: false, | ||
value: assignPathValue.bind(this), | ||
}) | ||
|
||
Object.defineProperty(this, 'get', { | ||
configurable: false, | ||
enumerable: false, | ||
writable: false, | ||
value: getPathValue.bind(this), | ||
}) | ||
constructor(notes) { | ||
if (notes && typeof notes === 'object') { | ||
Object.assign(this, notes) | ||
} | ||
|
||
Object.defineProperty(this, 'set', { | ||
configurable: false, | ||
enumerable: false, | ||
writable: false, | ||
value: assignPathValue.bind(this), | ||
}) | ||
|
||
Object.defineProperty(this, 'get', { | ||
configurable: false, | ||
enumerable: false, | ||
writable: false, | ||
value: getPathValue.bind(this), | ||
}) | ||
} | ||
} | ||
|
||
module.exports = Notes | ||
|
||
function getSegments(path) { | ||
// a dot.delimited.path | ||
if (typeof path === 'string') return path.split('.') | ||
// a dot.delimited.path | ||
if (typeof path === 'string') return path.split('.') | ||
|
||
// ['one', 'two', 'thr.ee'] | ||
if (Array.isArray(path)) return path | ||
// ['one', 'two', 'thr.ee'] | ||
if (Array.isArray(path)) return path | ||
} | ||
|
||
function assignPathValue(path, value) { | ||
if (path === undefined || value === undefined) return | ||
function assignPathValue(path, value, onlyWhenUndefined) { | ||
if (path === undefined || value === undefined) return | ||
|
||
const segments = getSegments(path) | ||
let dest = this | ||
const segments = getSegments(path) | ||
let dest = this | ||
|
||
while (segments.length > 1) { | ||
while (segments.length > 1) { | ||
// create any missing paths | ||
if (!dest[segments[0]]) dest[segments[0]] = {} | ||
// set dest one path segment deeper | ||
dest = dest[segments.shift()] | ||
} | ||
if (!dest[segments[0]]) dest[segments[0]] = {} | ||
// set dest one path segment deeper | ||
dest = dest[segments.shift()] | ||
} | ||
if (onlyWhenUndefined) { | ||
if (dest[segments[0]] === undefined) dest[segments[0]] = value | ||
} else { | ||
dest[segments[0]] = value | ||
} | ||
} | ||
|
||
function getPathValue(path) { | ||
if (!path) return | ||
const segments = getSegments(path) | ||
return segments.reduce((prev, curr) => { | ||
return prev ? prev[curr] : undefined | ||
}, this) | ||
if (!path) return | ||
const segments = getSegments(path) | ||
return segments.reduce((prev, curr) => { | ||
return prev ? prev[curr] : undefined | ||
}, this) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters