-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
42d4c1c
commit 0820b57
Showing
13 changed files
with
24 additions
and
9 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
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
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
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
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
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,14 +1,14 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import getRawDataFromBracesDeclaration from '../getRawDataFromBracesDeclaration'; | ||
import { objInnerToObj } from '../etc'; | ||
|
||
describe('objInnerToObj', () => { | ||
it('should return an obj, given a valid obj inner', () => { | ||
const objInner = ` | ||
foo: 'bar', | ||
bar: 'foo', | ||
`; | ||
expect(objInnerToObj(objInner)).toStrictEqual({ foo: 'bar', bar: 'foo' }); | ||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers | ||
const objInner = getRawDataFromBracesDeclaration(JSON.stringify({ foo: 'bar', bar: 'foo' }), 0); | ||
expect(objInner).not.toBe(null); | ||
expect(objInnerToObj(objInner as string)).toStrictEqual({ foo: 'bar', bar: 'foo' }); | ||
}); | ||
}); |
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,2 +1,6 @@ | ||
// eslint-disable-next-line | ||
/** | ||
* @danger {Eval} | ||
* NOTE: this function is DANGEROUS, use it wise and NEVER just send it an unchecked string. | ||
*/ | ||
// eslint-disable-next-line no-eval | ||
export const objInnerToObj = (objInner: string): any => eval('({\n' + objInner + '\n})'); |
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