yahoo / yahoo/serialize-javascript

Fails on native functions, like Number or String (SOLUTION INCLUDED)

Open
#179 4 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.