Skip to content

Serialization & Types improvements #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jan 22, 2018
Merged

Conversation

Akryum
Copy link
Member

@Akryum Akryum commented Jan 16, 2018

capture d ecran 2018-01-16 a 12 27 33

capture d ecran 2018-01-16 a 12 28 23

capture d ecran 2018-01-16 a 12 29 20

@Akryum
Copy link
Member Author

Akryum commented Jan 19, 2018

@evan @posva @michalsnik
I fixed #528 with a new EncodeCache class that should be used in front of any serialization involving CustomValue API.
I also changed the order of data and props sections to better follow the style guide. WDYT?

Guillaume Chau added 3 commits January 19, 2018 12:31
DataField: allowing to reproduce current available styling using CustomValue API
@Akryum
Copy link
Member Author

Akryum commented Jan 19, 2018

capture d ecran du 2018-01-19 12 45 30

@Akryum
Copy link
Member Author

Akryum commented Jan 19, 2018

I added some optimization from this branch: https://github.com/Akryum/vue-devtools/tree/component-inspect-optimizations (changes)

x10 faster when selecting the NativeTypes component after clicking the Create large array button.

It should help mitigate #515

@Akryum
Copy link
Member Author

Akryum commented Jan 19, 2018

@yyx990803 I also made a PR yyx990803/circular-json-es6#5 with the changes I made to CircularJSON.

@Akryum
Copy link
Member Author

Akryum commented Jan 20, 2018

I don't think we can serialize WeakMap since they are not iterable.

src/util.js Outdated
return {
_custom: {
type: 'function',
display: `<span>${func.name}</span>${args}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding the word function somewhere could make this more explicit. What about something like ƒ o(a, b, c), similar to the console?

@posva
Copy link
Member

posva commented Jan 20, 2018

Couldn't test open in editor yet, but everything else looks fine 🙂

@Akryum
Copy link
Member Author

Akryum commented Jan 20, 2018

capture d ecran du 2018-01-20 23 33 31


export function getCustomMapDetails (val) {
const list = []
val.forEach(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use map instead:

const list = val.map((value, key) => ({ key, value}))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Map doesn't have any map method.

export function reviveMap (val) {
const result = new Map()
const list = val._custom.value
for (let i = 0; i < list.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you can use forEach instead?

list.forEach(({ key, value}) =>
  result.set(key, reviver(null, value)
)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple loop without anonymous function call is faster imho. Also made a test case: https://jsperf.com/map-loop-vs-foreach (for what it's worth 🙃)

export function reviveSet (val) {
const result = new Set()
const list = val._custom.value
for (let i = 0; i < list.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

'$isChrome': { get: () => isChrome },
'$isWindows': { get: () => isWindows },
'$isMac': { get: () => isMac },
'$isLinus': { get: () => isLinux },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be $isLinux?

reg: /abc/gi,
testComponent: null,
hello: function foo (a, b, c) {},
hey: function empty () {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add anonymous function here and make sure it works good as well?
hi: function (a, b) {} should be displayed probably as f (a, b), also what about arrow functions? Or hi() {}?

@Akryum
Copy link
Member Author

Akryum commented Jan 22, 2018

@michalsnik
capture d ecran du 2018-01-22 11 25 10

@Akryum Akryum merged commit 842aa35 into vuejs:master Jan 22, 2018
@Akryum Akryum deleted the types-improvements branch January 22, 2018 14:12
@Akryum Akryum restored the types-improvements branch January 22, 2018 14:37
@Akryum Akryum deleted the types-improvements branch January 22, 2018 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants