-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
6,592 additions
and
9,365 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,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: mesqueeb | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
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,37 @@ | ||
name: Test | ||
on: | ||
push: | ||
branches: main | ||
paths: | ||
- src/** | ||
- test/** | ||
- '*.js' | ||
- '*.ts' | ||
- '*.json' | ||
- .github/workflows/test.yml | ||
pull_request: | ||
branches: main | ||
paths: | ||
- src/** | ||
- test/** | ||
- '*.js' | ||
- '*.ts' | ||
- '*.json' | ||
- .github/workflows/test.yml | ||
concurrency: | ||
group: test-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
node-version: ['18', '20'] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: npm | ||
- run: npm ci | ||
- run: npm test |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
import prettier from "@cycraft/eslint/prettier" | ||
|
||
export default prettier |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,36 +1,42 @@ | ||
import { isArray, isPlainObject } from 'is-what'; | ||
|
||
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) { | ||
const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable"; | ||
if (propType === "enumerable") | ||
carry[key] = newVal; | ||
if (includeNonenumerable && propType === "nonenumerable") { | ||
Object.defineProperty(carry, key, { | ||
value: newVal, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
}); | ||
} | ||
const propType = {}.propertyIsEnumerable.call(originalObject, key) | ||
? 'enumerable' | ||
: 'nonenumerable'; | ||
if (propType === 'enumerable') | ||
carry[key] = newVal; | ||
if (includeNonenumerable && propType === 'nonenumerable') { | ||
Object.defineProperty(carry, key, { | ||
value: newVal, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true, | ||
}); | ||
} | ||
} | ||
function copy(target, options = {}) { | ||
if (isArray(target)) { | ||
return target.map((item) => copy(item, options)); | ||
} | ||
if (!isPlainObject(target)) { | ||
return target; | ||
} | ||
const props = Object.getOwnPropertyNames(target); | ||
const symbols = Object.getOwnPropertySymbols(target); | ||
return [...props, ...symbols].reduce((carry, key) => { | ||
if (isArray(options.props) && !options.props.includes(key)) { | ||
return carry; | ||
/** | ||
* Copy (clone) an object and all its props recursively to get rid of any prop referenced of the original object. Arrays are also cloned, however objects inside arrays are still linked. | ||
* | ||
* @param target Target can be anything | ||
* @param [options = {}] Options can be `props` or `nonenumerable` | ||
* @returns the target with replaced values | ||
*/ | ||
export function copy(target, options = {}) { | ||
if (isArray(target)) { | ||
return target.map((item) => copy(item, options)); | ||
} | ||
if (!isPlainObject(target)) { | ||
return target; | ||
} | ||
const val = target[key]; | ||
const newVal = copy(val, options); | ||
assignProp(carry, key, newVal, target, options.nonenumerable); | ||
return carry; | ||
}, {}); | ||
const props = Object.getOwnPropertyNames(target); | ||
const symbols = Object.getOwnPropertySymbols(target); | ||
return [...props, ...symbols].reduce((carry, key) => { | ||
if (isArray(options.props) && !options.props.includes(key)) { | ||
return carry; | ||
} | ||
const val = target[key]; | ||
const newVal = copy(val, options); | ||
assignProp(carry, key, newVal, target, options.nonenumerable); | ||
return carry; | ||
}, {}); | ||
} | ||
|
||
export { copy }; |
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,10 @@ | ||
import config from '@cycraft/eslint/config' | ||
|
||
export default [ | ||
...config, | ||
{ | ||
rules: { | ||
'@typescript-eslint/no-explicit-any': 'warn', | ||
}, | ||
}, | ||
] |
Oops, something went wrong.