Skip to content
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

SparseMatrix: Allow cells to contain any Json #165

Merged
merged 8 commits into from
Sep 28, 2019
Merged

SparseMatrix: Allow cells to contain any Json #165

merged 8 commits into from
Sep 28, 2019

Conversation

DLehenbauer
Copy link
Contributor

Also introduces the Json type

* - Non-finite numbers (NaN, +/-Infinity) are coerced to `null`.
* - (null always marshalls as null)
*/
export type Json<T = JsonPrimitive> = T | JsonArray<T> | JsonObject<T>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Just FYI - May move to Tiny-Calc, as I need it there too. For now, I'm duplicating.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll want this in sequence for annotate, and probably map/directory too. FYI: @ChumpChief

Also, rather than Json, maybe go with Serializable as the prefix?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, yes this would be helpful for the container-like DDSs. JSON seems OK as prefix in that context, since we don't specifically require our DDSs to serialize to JSON (e.g. maybe eventually Ink serializes to ISF or InkML).

import { ISharedObject, ISharedObjectFactory } from "@microsoft/fluid-shared-object-base";
import { SharedSegmentSequence, SubSequence } from "./";
import { pkgVersion } from "./packageVersion";

export type UnboxedOper = undefined | boolean | number | string;
type Cell = Json<JsonPrimitive | IComponentHandle>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kurtb - The above shows how to type a value to 'any Json + IComponentHandle'.

@DLehenbauer
Copy link
Contributor Author

Fixes #138

// tslint:disable:interface-name

export type JsonPrimitive = undefined | null | boolean | number | string;
export interface JsonObject<T> extends Record<string, T | JsonArray<T> | JsonObject<T>> { }
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be Json<T>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice. :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some suffix we could put on Json, maybe JsonContent or similar? To avoid accidental conflation of Json and JSON.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Jsonable gets several pages of relevant search results.

@DLehenbauer DLehenbauer merged commit 7c77996 into master Sep 28, 2019
@DLehenbauer DLehenbauer deleted the json branch October 1, 2019 19:06
hixio-mh added a commit to hixio-mh/FluidFramework that referenced this pull request Dec 30, 2021
…40363657aa48d6285a

[Snyk] Security upgrade mocha from 8.4.0 to 9.1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants