Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Uncaught TypeError: sort is not a function #1599

Closed
mccoysc opened this issue Sep 28, 2018 · 3 comments
Closed

Uncaught TypeError: sort is not a function #1599

mccoysc opened this issue Sep 28, 2018 · 3 comments

Comments

@mccoysc
Copy link

mccoysc commented Sep 28, 2018

Uncaught TypeError: sort is not a function
at Function.e.exports [as create] (create.js:39)
at Object.t.deserialize (util.js:75)
at y (index.js:376)
at c (waterfall.js:16)
at f (waterfall.js:23)
at onlyOnce.js:12
at getMany (index.js:207)
at map.js:32
at once.js:12
at f (eachOf.js:60)
at onlyOnce.js:12
at map.js:29
at once.js:12
at f (waterfall.js:21)
at onlyOnce.js:12
at e.get (blockstore.js:84)

code:
const sortedLinks = sort(links, linkSort)
@ipld-dag-pb/src/dag-node/create.js:39

@mccoysc
Copy link
Author

mccoysc commented Sep 28, 2018

this maybe caused by the stable.js at line 5 which end with ":".
when loaded,throw an warning:unexpected token

@alanshaw
Copy link
Member

@mccoysc do you have some example code you can post so that we can reproduce the error?

@mccoysc
Copy link
Author

mccoysc commented Sep 28, 2018

the error is not caused by my code using.
it's caused by the bad write code:

typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.stable = factory());

for no any ";" used,may webpack compile these code in an improper way and then cause a illegal compiled code.

so,i modify the original code and make a mistake and cause an error.

but still, i suggest you change the code like this:
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = factory();
} else {
if (typeof define === 'function' && define.amd) {
define(factory);
}esle{
global.stable = factory();
}
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants