How to use the memoize-one.default function in memoize-one

To help you get started, we’ve selected a few memoize-one examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github praneshr / react-diff-viewer / src / index.tsx View on Github external
import * as PropTypes from 'prop-types';
import cn from 'classnames';

import {
  computeLineInformation,
  LineInformation,
  DiffInformation,
  DiffType,
  DiffMethod,
} from './compute-lines';
import computeStyles, { ReactDiffViewerStylesOverride, ReactDiffViewerStyles } from './styles';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const m = require('memoize-one');

const memoize = m.default || m;

export enum LineNumberPrefix {
  LEFT = 'L',
  RIGHT = 'R',
}

export interface ReactDiffViewerProps {
  // Old value to compare.
  oldValue: string;
  // New value to compare.
  newValue: string;
  // Enable/Disable split view.
  splitView?: boolean;
  // Enable/Disable word diff.
  disableWordDiff?: boolean;
  // JsDiff text diff method from https://github.com/kpdecker/jsdiff/tree/v4.0.1#api
github Decathlon / react-table / src / components / utils / table.tsx View on Github external
import * as React from "react";
import { merge } from "lodash";
import * as memoize from "memoize-one";
import update from "immutability-helper";

import { DEFAULT_ROW_HEIGHT, MouseClickButtons } from "../constants";
import { IColumn, ITree, IColumns, ITrees } from "../table/elementary-table";
import { IRowOptions, IRow } from "../table/row";
import { ICell, ICellCoordinates } from "../table/cell";
import { Nullable } from "../typing";
import { isEmptyObj } from "./common";
import shallowEqual from "./shallowEqual";

// @ts-ignore https://github.com/s-yadav/react-number-format/issues/180
const memoizeFunc = memoize.default || memoize;

export enum ElevationType {
  start = "start",
  end = "end"
}

export interface IElevateds {
  [key: string]: ElevationType;
}

export interface IAbsoluteIndex {
  index: number;
  parentIndex: Nullable;
}

export interface IRelativeIndex {
github DonJayamanne / pythonVSCode / src / datascience-ui / interactive-common / variableExplorer.tsx View on Github external
this.state = { gridColumns: columns,
                       gridHeight: 200,
                       height: 0,
                       fontSize: 14,
                       sortColumn: 'name',
                       sortDirection: 'NONE'};

        this.divRef = React.createRef();

        // Memoize is different between the tests running and webpack. figure out which one
        // tslint:disable-next-line: no-any
        let memoize_func : any | undefined;
        if (memoize instanceof Function) {
            memoize_func = memoize;
        } else {
            memoize_func = memoize.default;
        }
        this.generateRows = memoize_func((variables: IJupyterVariable[], sortColumn: string | number, sortDirection: string): IGridRow[] => {
            const rows = !this.props.skipDefault ? this.generateDummyVariables() : this.parseVariables(variables);
            return this.internalSortRows(rows, sortColumn, sortDirection);
        });
    }
github transloadit / uppy / packages / @uppy / dashboard / src / index.js View on Github external
const { Plugin } = require('@uppy/core')
const Translator = require('@uppy/utils/lib/Translator')
const DashboardUI = require('./components/Dashboard')
const StatusBar = require('@uppy/status-bar')
const Informer = require('@uppy/informer')
const ThumbnailGenerator = require('@uppy/thumbnail-generator')
const findAllDOMElements = require('@uppy/utils/lib/findAllDOMElements')
const toArray = require('@uppy/utils/lib/toArray')
const getDroppedFiles = require('@uppy/utils/lib/getDroppedFiles')
const trapFocus = require('./utils/trapFocus')
const cuid = require('cuid')
const ResizeObserver = require('resize-observer-polyfill').default || require('resize-observer-polyfill')
const { defaultPickerIcon } = require('./components/icons')
const createSuperFocus = require('./utils/createSuperFocus')
const memoize = require('memoize-one').default || require('memoize-one')

const TAB_KEY = 9
const ESC_KEY = 27

function createPromise () {
  const o = {}
  o.promise = new Promise((resolve, reject) => {
    o.resolve = resolve
    o.reject = reject
  })
  return o
}

/**
 * Dashboard UI with previews, metadata editing, tabs for various services and more
 */

memoize-one

A memoization library which only remembers the latest invocation

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis