How to use nullthrows - 10 common examples

To help you get started, we’ve selected a few nullthrows 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 facebook / react-devtools / frontend / Node.js View on Github external
);
    }

    let name = node.get('name') + '';

    // If the user's filtering then highlight search terms in the tag name.
    // This will serve as a visual reminder that the visible tree is filtered.
    if (searchRegExp) {
      const unmatched = name.split(searchRegExp);
      const matched = name.match(searchRegExp);
      const pieces = [
        <span>{unmatched.shift()}</span>,
      ];
      while (unmatched.length &gt; 0) {
        pieces.push(
          <span style="{highlightStyle(theme)}">{nullthrows(matched).shift()}</span>
        );
        pieces.push(
          <span>{unmatched.shift()}</span>
        );
      }

      name = pieces;
    }

    const dollarRStyle = {
      color: isWindowFocused ? getInvertedWeak(theme.state02) : 'inherit',
    };

    // Single-line tag (collapsed / simple content / no content)
    if (!children || typeof children === 'string' || !children.length) {
      const jsxSingleLineTagStyle = jsxTagStyle(inverted, nodeType, theme);
github facebookarchive / atom-ide-ui / modules / atom-ide-ui / pkg / atom-ide-debugger / lib / vsp / DebuggerModel.js View on Github external
async refreshCallStack(levels: ?number): Promise {
    if (!this.stopped) {
      return;
    }

    const supportsDelayLoading =
      nullthrows(this.process).session.capabilities
        .supportsDelayedStackTraceLoading === true;

    this._refreshInProgress = true;
    try {
      if (supportsDelayLoading) {
        const start = this._callStack.callFrames.length;
        const callStack = await this._getCallStackImpl(start, levels);
        if (start &lt; this._callStack.callFrames.length) {
          // Set the stack frames for exact position we requested.
          // To make sure no concurrent requests create duplicate stack frames #30660
          this._callStack.callFrames.splice(
            start,
            this._callStack.callFrames.length - start,
          );
        }
        this._callStack.callFrames = this._callStack.callFrames.concat(
github parcel-bundler / parcel / packages / core / workers / src / child.js View on Github external
handleResponse(data: WorkerResponse): void {
    let idx = nullthrows(data.idx);
    let contentType = data.contentType;
    let content = data.content;
    let call = nullthrows(this.responseQueue.get(idx));

    if (contentType === 'error') {
      invariant(typeof content !== 'string');
      call.reject(new ThrowableDiagnostic({diagnostic: content}));
    } else {
      call.resolve(content);
    }

    this.responseQueue.delete(idx);

    // Process the next call
    this.processQueue();
  }
github facebook / react-devtools / shells / plain / container.js View on Github external
window.addEventListener('keydown', function(e) {
  const body = nullthrows(document.body);
  if (e.altKey && e.keyCode === 68) { // Alt + D
    if (body.className === 'devtools-bottom') {
      body.className = 'devtools-right';
    } else {
      body.className = 'devtools-bottom';
    }
  }
});
github facebook / react-devtools / shells / webextension / src / GlobalHook.js View on Github external
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.nativeWeakMap = WeakMap;
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.nativeSet = Set;
`;

var js = (
  ';(' + installGlobalHook.toString() + '(window))' +
  saveNativeValues +
  detectReact
);

// This script runs before the  element is created, so we add the script
// to  instead.
var script = document.createElement('script');
script.textContent = js;
nullthrows(document.documentElement).appendChild(script);
nullthrows(script.parentNode).removeChild(script);
github expo / expo / tools / android-versioning / android-expolib.js View on Github external
function _parseJarJarRule(line) {
  let [type, ...parts] = line.trim().split(/\s+/);
  if (type === 'rule') {
    return { type, match: nullthrows(parts[0]), replace: nullthrows(parts[1]) };
  } else if (type === 'zap' || type === 'keep') {
    return { type, match: nullthrows(parts[0]) };
  }
  throw new Error(`Unknown Jar Jar rule: ${line}`);
}
github parcel-bundler / parcel / packages / core / core / src / Transformation.js View on Github external
filePath,
      pipelineName,
    );
    let pipeline = {
      id: transformers.map(t => t.name).join(':'),

      transformers: transformers.map(transformer => ({
        name: transformer.name,
        config: configs.get(transformer.name)?.result,
        plugin: transformer.plugin,
      })),
      configs,
      options: this.options,
      resolverRunner: new ResolverRunner({
        config: new ParcelConfig(
          nullthrows(nullthrows(configs.get('parcel')).result),
          this.options.packageManager,
        ),
        options: this.options,
      }),

      pluginOptions: new PluginOptions(this.options),
      workerApi: this.workerApi,
    };

    return pipeline;
  }
github facebookarchive / atom-ide-ui / modules / nuclide-commons-ui / spec / openPreview-spec.js View on Github external
function getActiveTextEditor(): atom$TextEditor {
  return nullthrows(atom.workspace.getActiveTextEditor());
}
github magma / magma / symphony / app / fbcnms-packages / fbcnms-ui / components / design-system / FormField / FormField.js View on Github external
className={classNames(
          classes.root,
          {[classes.disabled]: disabled},
          {[classes.hasError]: hasError},
          className,
        )}&gt;
        {label &amp;&amp; (
          
        )}
        {children}
        {(helpText || (hasError &amp;&amp; errorText)) &amp;&amp; (
          
        )}
        {!helpText &amp;&amp; !hasError &amp;&amp; hasSpacer &amp;&amp; (
          <div>
        )}
      </div>
    
  );
};
github parcel-bundler / parcel / packages / core / core / src / ConfigLoader.js View on Github external
async loadPluginConfig({
    plugin,
    env,
    isSource,
    filePath,
    meta: {parcelConfigPath},
  }: ConfigRequestDesc) {
    let config = createConfig({
      isSource,
      searchPath: filePath,
      env,
    });
    invariant(typeof parcelConfigPath === 'string');
    let pluginInstance = await loadPlugin(
      this.options.packageManager,
      nullthrows(plugin),
      parcelConfigPath,
    );
    if (pluginInstance.loadConfig != null) {
      await pluginInstance.loadConfig({
        config: new Config(config, this.options),
        options: this.options,
        logger: new PluginLogger({origin: nullthrows(plugin)}),
      });
    }

    return config;
  }
}

nullthrows

flow typed nullthrows

MIT
Latest version published 5 years ago

Package Health Score

65 / 100
Full package analysis

Popular nullthrows functions