How to use tiny-warning - 10 common examples

To help you get started, we’ve selected a few tiny-warning 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 NoahZinsmeister / web3-react / packages / injected-connector / src / index.ts View on Github external
if ((window.ethereum as any).isMetaMask) {
      ;(window.ethereum as any).autoRefreshOnNetworkChange = false
    }

    // try to activate + get account via eth_requestAccounts
    let account
    try {
      account = await (window.ethereum.send as Send)('eth_requestAccounts').then(
        sendReturn => parseSendReturn(sendReturn)[0]
      )
    } catch (error) {
      if ((error as any).code === 4001) {
        throw new UserRejectedRequestError()
      }
      warning(false, 'eth_requestAccounts was unsuccessful, falling back to enable')
    }

    // if unsuccessful, try enable
    if (!account) {
      // if enable is successful but doesn't return accounts, fall back to getAccount (not happy i have to do this...)
      account = await window.ethereum.enable().then(sendReturn => sendReturn && parseSendReturn(sendReturn)[0])
    }

    return { provider: window.ethereum, ...(account ? { account } : {}) }
  }
github ianstormtaylor / slate / packages / slate-react / src / components / content.js View on Github external
// If the Slate selection is focused, but the DOM's active element is not
    // the editor, we need to focus it. We prevent scrolling because we handle
    // scrolling to the correct selection.
    if (selection.isFocused && activeElement !== this.ref.current) {
      this.ref.current.focus({ preventScroll: true })
      updated = true
    }

    // Otherwise, figure out which DOM nodes should be selected...
    if (selection.isFocused && selection.isSet) {
      const current = !!native.rangeCount && native.getRangeAt(0)
      const range = editor.findDOMRange(selection)

      if (!range) {
        warning(
          false,
          'Unable to find a native DOM range from the current selection.'
        )

        return
      }

      const { startContainer, startOffset, endContainer, endOffset } = range

      // If the new range matches the current selection, there is nothing to fix.
      // COMPAT: The native `Range` object always has it's "start" first and "end"
      // last in the DOM. It has no concept of "backwards/forwards", so we have
      // to check both orientations here. (2017/10/31)
      if (current) {
        if (
          (startContainer === current.startContainer &&
github sikidamjanovic / cowrite / node_modules / history / esm / history.js View on Github external
function replace(path, state) {
    process.env.NODE_ENV !== "production" ? warning(state === undefined, 'Hash history cannot replace state; it is ignored') : void 0;
    var action = 'REPLACE';
    var location = createLocation(path, undefined, undefined, history.location);
    transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
      if (!ok) return;
      var path = createPath(location);
      var encodedPath = encodePath(basename + path);
      var hashChanged = getHashPath() !== encodedPath;

      if (hashChanged) {
        // We cannot tell if a hashchange was caused by a REPLACE, so we'd
        // rather setState here and ignore the hashchange. The caveat here
        // is that other hash histories in the page will consider it a POP.
        ignorePath = path;
        replaceHashPath(encodedPath);
      }
github ianstormtaylor / slate / packages / slate / src / interfaces / element.js View on Github external
getBlocksAsArray() {
    warning(
      false,
      'As of slate@0.47, the `getBlocksAsArray` method is deprecated.'
    )

    const iterable = this.blocks({ onlyLeaves: true })
    const array = Array.from(iterable, ([node]) => node)
    return array
  }
github tdeekens / flopflip / packages / launchdarkly-adapter / modules / adapter / adapter.ts View on Github external
updateUserContext(updatedUserProps: User): Promise {
    const isAdapterReady = adapterState.isConfigured && adapterState.isReady;

    warning(
      isAdapterReady,
      '@flopflip/launchdarkly-adapter: adapter not ready and configured. User context can not be updated before.'
    );

    if (!isAdapterReady)
      return Promise.reject(
        new Error('Can not update user context: adapter not yet ready.')
      );

    return changeUserContext({ ...adapterState.user, ...updatedUserProps });
  }
github sikidamjanovic / cowrite / node_modules / history / esm / history.js View on Github external
function replace(path, state) {
    process.env.NODE_ENV !== "production" ? warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;
    var action = 'REPLACE';
    var location = createLocation(path, state, createKey(), history.location);
    transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
      if (!ok) return;
      history.entries[history.index] = location;
      setState({
        action: action,
        location: location
      });
    });
  }
github ianstormtaylor / slate / packages / slate / src / controllers / editor.js View on Github external
applyOperations(operations) {
    warning(
      false,
      'As of Slate 0.43 the `applyOperations` method is deprecated, please apply each operation in a loop instead.'
    )

    operations.forEach(op => this.applyOperation(op))
    return this.controller
  }
github ianstormtaylor / slate / packages / slate / src / interfaces / element.js View on Github external
getPreviousMatchingNodeAndPath(path, iterator = () => true) {
    warning(
      false,
      'As of slate@0.47, the `getPreviousMatchingNodeAndPath` method is deprecated.'
    )

    if (!path) return null

    for (let i = path.size; i > 0; i--) {
      const p = path.slice(0, i)
      if (p.last() === 0) continue

      let previousPath = PathUtils.decrement(p)
      let previousNode = this.getNode(previousPath)

      while (previousNode && !iterator(previousNode)) {
        previousPath = PathUtils.decrement(previousPath)
        previousNode = this.getNode(previousPath)
github ReactTraining / react-router / packages / react-router / modules / Switch.js View on Github external
Switch.prototype.componentDidUpdate = function(prevProps) {
    warning(
      !(this.props.location && !prevProps.location),
      '
github ReactTraining / react-router / packages / react-router / modules / Router.js View on Github external
Router.prototype.componentDidUpdate = function(prevProps) {
    warning(
      prevProps.history === this.props.history,
      "You cannot change "
    );
  };
}

tiny-warning

A tiny warning function

MIT
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis

Popular tiny-warning functions