@nteract/commutable
Advanced tools
Comparing version 3.1.3 to 4.0.0
@@ -39,2 +39,3 @@ "use strict"; | ||
if (Immutable.Map.isMap(notebook)) { | ||
// $FlowFixMe: isMap doesn't hint to flow that this is an Immutable | ||
var immNotebook = notebook; | ||
@@ -47,2 +48,3 @@ if (immNotebook.has("cellOrder") && immNotebook.has("cellMap")) { | ||
// $FlowFixMe: isMap doesn't hint to flow that this is a plain Object | ||
var notebookJSON = notebook; | ||
@@ -66,3 +68,5 @@ | ||
function toJS(immnb) { | ||
if (immnb.get("nbformat") === 4 && immnb.get("nbformat_minor") >= 0) { | ||
var minorVersion = immnb.get("nbformat_minor", null); | ||
if (immnb.get("nbformat") === 4 && typeof minorVersion === "number" && minorVersion >= 0) { | ||
return v4.toJS(immnb); | ||
@@ -69,0 +73,0 @@ } |
{ | ||
"name": "@nteract/commutable", | ||
"version": "3.1.3", | ||
"version": "4.0.0", | ||
"description": "library for immutable notebook operations", | ||
"main": "index.js", | ||
"main": "lib/index.js", | ||
"nteractDesktop": "src/index.js", | ||
@@ -29,3 +29,3 @@ "scripts": { | ||
"dependencies": { | ||
"@nteract/types": "^1.3.3", | ||
"@nteract/types": "^2.0.0", | ||
"immutable": "^4.0.0-rc.9", | ||
@@ -32,0 +32,0 @@ "uuid": "^3.1.0" |
@@ -6,6 +6,39 @@ /* @flow */ | ||
import type { ImmutableNotebook, JSONType } from "@nteract/types/commutable"; | ||
import * as Immutable from "immutable"; | ||
export type ExecutionCount = number | null; | ||
export type MimeBundle = JSONObject; | ||
export type CellType = "markdown" | "code"; | ||
export type CellID = string; | ||
import type { | ||
ImmutableNotebook, | ||
ImmutableCodeCell, | ||
ImmutableMarkdownCell, | ||
ImmutableRawCell, | ||
ImmutableCell, | ||
ImmutableOutput, | ||
ImmutableOutputs, | ||
ImmutableMimeBundle, | ||
ImmutableJSONType, | ||
ImmutableCellOrder, | ||
ImmutableCellMap | ||
} from "./types"; | ||
export type { | ||
ImmutableCellOrder, | ||
ImmutableCellMap, | ||
ImmutableNotebook, | ||
ImmutableCodeCell, | ||
ImmutableMarkdownCell, | ||
ImmutableRawCell, | ||
ImmutableCell, | ||
ImmutableOutput, | ||
ImmutableOutputs, | ||
ImmutableMimeBundle, | ||
ImmutableJSONType | ||
}; | ||
const v4 = require("./v4"); | ||
@@ -43,2 +76,3 @@ const v3 = require("./v3"); | ||
if (Immutable.Map.isMap(notebook)) { | ||
// $FlowFixMe: isMap doesn't hint to flow that this is an Immutable | ||
const immNotebook: ImmutableNotebook = notebook; | ||
@@ -53,2 +87,3 @@ if (immNotebook.has("cellOrder") && immNotebook.has("cellMap")) { | ||
// $FlowFixMe: isMap doesn't hint to flow that this is a plain Object | ||
const notebookJSON: Notebook = notebook; | ||
@@ -79,3 +114,9 @@ | ||
function toJS(immnb: ImmutableNotebook): v4Notebook { | ||
if (immnb.get("nbformat") === 4 && immnb.get("nbformat_minor") >= 0) { | ||
const minorVersion: null | number = immnb.get("nbformat_minor", null); | ||
if ( | ||
immnb.get("nbformat") === 4 && | ||
typeof minorVersion === "number" && | ||
minorVersion >= 0 | ||
) { | ||
return v4.toJS(immnb); | ||
@@ -111,3 +152,1 @@ } | ||
}; | ||
export type { ImmutableNotebook }; |
@@ -7,6 +7,2 @@ // @flow | ||
export type JSONType = PrimitiveImmutable | JSONObject | JSONArray; // eslint-disable-line no-use-before-define | ||
export type JSONObject = { [key: string]: JSONType }; | ||
export type JSONArray = Array<JSONType>; | ||
export type ImmutableJSONType = | ||
@@ -13,0 +9,0 @@ | PrimitiveImmutable |
/* @flow */ | ||
/* eslint-disable array-callback-return, prefer-spread */ | ||
import type { | ||
JSONObject, | ||
ImmutableNotebook, | ||
@@ -6,0 +5,0 @@ ImmutableCodeCell, |
@@ -20,4 +20,2 @@ /* @flow */ | ||
import type { | ||
JSONType, | ||
JSONObject, | ||
ImmutableNotebook, | ||
@@ -24,0 +22,0 @@ ImmutableCodeCell, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80594
1586
+ Added@nteract/types@2.1.0(transitive)
- Removed@nteract/types@1.3.3(transitive)
Updated@nteract/types@^2.0.0