@nteract/commutable
Advanced tools
Comparing version 2.1.2 to 2.2.0
@@ -5,2 +5,8 @@ "use strict"; | ||
var _immutable = require("immutable"); | ||
var Immutable = _interopRequireWildcard(_immutable); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var v4 = require("./v4"); | ||
@@ -31,3 +37,15 @@ var v3 = require("./v3"); | ||
function fromJS(notebookJSON) { | ||
function fromJS(notebook) { | ||
if (Immutable.Map.isMap(notebook)) { | ||
// $FlowFixMe: Immutable | ||
var immNotebook = notebook; | ||
if (immNotebook.has("cellOrder") && immNotebook.has("cellMap")) { | ||
return immNotebook; | ||
} | ||
throw new TypeError("commutable was passed an Immutable.Map structure that is not a notebook"); | ||
} | ||
// $FlowFixMe: Immutable | ||
var notebookJSON = notebook; | ||
if (notebookJSON.nbformat === 4 && notebookJSON.nbformat_minor >= 0) { | ||
@@ -34,0 +52,0 @@ if (Array.isArray(notebookJSON.cells) && _typeof(notebookJSON.metadata) === "object") { |
@@ -48,3 +48,3 @@ "use strict"; | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Output Types | ||
@@ -54,3 +54,3 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Cell Types | ||
@@ -57,0 +57,0 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
{ | ||
"name": "@nteract/commutable", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "library for immutable notebook operations", | ||
@@ -15,7 +15,8 @@ "main": "index.js", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/nteract/nteract/tree/master/packages/commutable" | ||
}, | ||
"keywords": ["commutable", "nteract", "notebooks"], | ||
"repository": "https://github.com/nteract/nteract/tree/master/packages/commutable", | ||
"keywords": [ | ||
"commutable", | ||
"nteract", | ||
"notebooks" | ||
], | ||
"publishConfig": { | ||
@@ -22,0 +23,0 @@ "access": "public" |
@@ -8,2 +8,4 @@ /* @flow */ | ||
import * as Immutable from "immutable"; | ||
type PlaceholderNotebook = { | ||
@@ -44,3 +46,17 @@ nbformat: number, | ||
function fromJS(notebookJSON: Notebook): ImmutableNotebook { | ||
function fromJS(notebook: Notebook | ImmutableNotebook): ImmutableNotebook { | ||
if (Immutable.Map.isMap(notebook)) { | ||
// $FlowFixMe: Immutable | ||
const immNotebook: ImmutableNotebook = notebook; | ||
if (immNotebook.has("cellOrder") && immNotebook.has("cellMap")) { | ||
return immNotebook; | ||
} | ||
throw new TypeError( | ||
`commutable was passed an Immutable.Map structure that is not a notebook` | ||
); | ||
} | ||
// $FlowFixMe: Immutable | ||
const notebookJSON: Notebook = notebook; | ||
if (notebookJSON.nbformat === 4 && notebookJSON.nbformat_minor >= 0) { | ||
@@ -59,3 +75,5 @@ if ( | ||
throw new TypeError( | ||
`nbformat v${notebookJSON.nbformat}.${notebookJSON.nbformat_minor} not recognized` | ||
`nbformat v${notebookJSON.nbformat}.${ | ||
notebookJSON.nbformat_minor | ||
} not recognized` | ||
); | ||
@@ -62,0 +80,0 @@ } |
@@ -53,3 +53,3 @@ /* @flow */ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Output Types | ||
@@ -85,3 +85,3 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Cell Types | ||
@@ -88,0 +88,0 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
77463
1536
1