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

Move most of perseus - util.ts into perseus-core - util.ts #2089

Closed
wants to merge 14 commits into from
10 changes: 10 additions & 0 deletions .changeset/twelve-timers-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@khanacademy/perseus": major
"@khanacademy/perseus-score": major
"@khanacademy/kmath": minor
"@khanacademy/perseus-core": minor
"@khanacademy/perseus-dev-ui": patch
"@khanacademy/perseus-editor": patch
---

Init perseus-score, move AnswerTypes from perseus to perseus-score, move perseus-types in perseus to data-schema in perseus-core
2 changes: 1 addition & 1 deletion dev/flipbook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import type {
PerseusScore,
PerseusWidget,
} from "../packages/perseus/src";
import type {InteractiveGraphWidget} from "../packages/perseus/src/perseus-types";
import type {InteractiveGraphWidget} from "@khanacademy/perseus-core";
import type {PropsFor} from "@khanacademy/wonder-blocks-core";

import "../packages/perseus/src/styles/perseus-renderer.less";
Expand Down
2 changes: 2 additions & 0 deletions packages/kmath/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export * as vector from "./vector";
export * as point from "./point";
export * as line from "./line";
export * as ray from "./ray";

export {default as KhanMath, sum} from "./math";
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {number as knumber} from "@khanacademy/kmath";
import $ from "jquery";
import _ from "underscore";

import type {MathFormat} from "../perseus-types";
import {number as knumber} from "@khanacademy/kmath";

import type {MathFormat} from "@khanacademy/perseus-core";

const KhanMath = {
// Simplify formulas before display
Expand Down
6 changes: 6 additions & 0 deletions packages/perseus-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ export {libVersion} from "./version";

export {Errors} from "./error/errors";
export {PerseusError} from "./error/perseus-error";

export * from "./data-schema";

export {pluck, mapObject, clone} from "./utils/object-utils";
export {default as Util} from "./utils/util";
export type {GridDimensions, Position} from "./utils/util";
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/**
* A work-in-progress of _ methods for objects.
* That is, they take an object as a parameter,
* and return an object instead of an array.
*
* TODO(aria): Move this out of interactive2
* Utilities for objects
*/

import _ from "underscore";
Expand Down Expand Up @@ -52,3 +48,13 @@ export const mapObject = function <K extends string, V, U>(
});
return result;
};

// Performs a deep copy of the given object. If there are cycles in the object
// tree, an error is thrown.
export const clone = <T>(obj: T): T => {
const json = JSON.stringify(obj);
if (!json) {
throw new Error("Oops, couldn't clone given object!");
}
return JSON.parse(json);
};
Loading
Loading