Skip to content

Commit

Permalink
Merge pull request #23 from isahohieku/isahohieku-add-raw-json-capabi…
Browse files Browse the repository at this point in the history
…lity

Allows for numbers to be used as keys
  • Loading branch information
tonyketcham authored Jan 17, 2024
2 parents d21e828 + 2558b7b commit 5628484
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ exclude?: FilterPattern;
* @see https://github.com/nodeca/js-yaml/blob/49baadd52af887d2991e2c39a6639baa56d6c71b/README.md#load-string---options-
*/
schema?: Schema;
/**
* A boolean to determine if JSON object should be serialized.
*
* @see https://www.npmjs.com/package/tosource for the motivation behind serialization of JSON.
*/
raw?: boolean;
/**
* A function that will be called for error reporting.
*
Expand Down
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export type PluginOptions = {
* @see https://github.com/nodeca/js-yaml/blob/49baadd52af887d2991e2c39a6639baa56d6c71b/README.md#load-string---options-
*/
schema?: Schema;
/**
* A boolean to determine if JSON object should be serialized.
*
* @see https://www.npmjs.com/package/tosource for the motivation behind serialization of JSON.
*/
raw?: boolean;
/**
* A function that will be called for error reporting.
*
Expand Down Expand Up @@ -67,7 +73,7 @@ export default (
});

return {
code: `const data = ${toSource(yamlData)};\nexport default data;`,
code: `const data = ${options.raw ? yamlData : toSource(yamlData)};\nexport default data;`,
map: { mappings: "" },
};
}
Expand Down

0 comments on commit 5628484

Please sign in to comment.