yahoo / yahoo/serialize-javascript
Fails on native functions, like Number or String (SOLUTION INCLUDED)
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.9k
- Forks
- 215
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 2
Description
Steps to Reproduce:
const serializeJavaScript = require('serialize-javascript');
const input = {
type: Number
};
const output = serializeJavaScript(input);
console.log(output);
Expected:
'{"type":Number}'
Actual:
Uncaught TypeError: Serializing native function: Number
at serializeFunc (/node_modules/serialize-javascript/index.js:146:17)
at /node_modules/serialize-javascript/index.js:266:16
at String.replace (<anonymous>)
at serialize (/node_modules/serialize-javascript/index.js:220:16)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at serialize-javascript/index.js, especially serializeFunc around line 146 and the replacement path around lines 220 and 266, then run the JavaScript reproduction from the issue. Done means serializing an object containing Number or String produces '{"type":Number}' rather than throwing a native-function TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100