trim lodash usage, remove unused module

This commit is contained in:
Vyacheslav Matyukhin 2022-09-19 22:00:01 +04:00
parent f8b743feb5
commit 674213360c
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
5 changed files with 11 additions and 34 deletions

View File

@ -1,20 +0,0 @@
open Jest
open Expect
let makeTest = (~only=false, str, item1, item2) =>
only
? Only.test(str, () => expect(item1)->toEqual(item2))
: test(str, () => expect(item1)->toEqual(item2))
describe("Lodash", () =>
describe("Lodash", () => {
makeTest("min", Lodash.min([1, 3, 4]), 1)
makeTest("max", Lodash.max([1, 3, 4]), 4)
makeTest("uniq", Lodash.uniq([1, 3, 4, 4]), [1, 3, 4])
makeTest(
"countBy",
Lodash.countBy([1, 3, 4, 4], r => r),
Js.Dict.fromArray([("1", 1), ("3", 1), ("4", 2)]),
)
})
)

View File

@ -1,4 +1,4 @@
import * as _ from "lodash";
import zipWith from "lodash/zipWith";
import { wrapDistribution } from "./SqDistribution";
import * as RSPointSetDist from "../rescript/ForTS/ForTS_Distribution/ForTS_Distribution_PointSetDistribution.gen";
import { pointSetDistributionTag as Tag } from "../rescript/ForTS/ForTS_Distribution/ForTS_Distribution_PointSetDistribution_tag";
@ -16,7 +16,7 @@ const shapePoints = (
): SqPoint[] => {
let xs = x.xyShape.xs;
let ys = x.xyShape.ys;
return _.zipWith(xs, ys, (x, y) => ({ x, y }));
return zipWith(xs, ys, (x, y) => ({ x, y }));
};
export const wrapPointSetDist = (value: T) => {

View File

@ -1,5 +1,6 @@
const pdfast = require("pdfast");
const _ = require("lodash");
const filter = require("lodash/filter");
const isFinite = require("lodash/isFinite");
const samplesToContinuousPdf = (
samples,
@ -8,12 +9,12 @@ const samplesToContinuousPdf = (
min = false,
max = false
) => {
let _samples = _.filter(samples, _.isFinite);
if (_.isFinite(min)) {
_samples = _.filter(_samples, (r) => r > min);
let _samples = filter(samples, isFinite);
if (isFinite(min)) {
_samples = filter(_samples, (r) => r > min);
}
if (_.isFinite(max)) {
_samples = _.filter(_samples, (r) => r < max);
if (isFinite(max)) {
_samples = filter(_samples, (r) => r < max);
}
// The pdf that's created from this function is not a pdf but a pmf. y values

View File

@ -1,5 +0,0 @@
@module("lodash") external min: array<'a> => 'a = "min"
@module("lodash") external max: array<'a> => 'a = "max"
@module("lodash") external uniq: array<'a> => array<'a> = "uniq"
@module("lodash")
external countBy: (array<'a>, 'a => 'b) => Js.Dict.t<int> = "countBy"

View File

@ -12,7 +12,8 @@
"declarationDir": "./dist",
"declaration": true,
"composite": true,
"target": "ES6"
"target": "ES6",
"esModuleInterop": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts", "webpack.config.js"]