How to use the promise.prototype.finally.shim function in promise

To help you get started, we’ve selected a few promise 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 mozilla / qbrt / test / run-path-missing-package.js View on Github external
* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. */

'use strict';

// Polyfill Promise.prototype.finally().
require('promise.prototype.finally').shim();

const fs = require('fs-extra');
const os = require('os');
const path = require('path');
const spawn = require('child_process').spawn;
const tap = require('tap');

let exitCode = 0;
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'qbrt-test-'));

new Promise((resolve, reject) => {
  // Copy the app to a temporary directory to avoid qbrt finding
  // the package.json file for qbrt itself when looking for the package
  // for the test app.
  const sourceDir = path.join('test', 'hello-world-missing-package');
  const destDir = path.join(tempDir, 'hello-world-missing-package');
github infinispan / js-client / spec / utils / testing.js View on Github external
// Commons functions

var _ = require('underscore');

var log4js = require('log4js');

var promiseFinally = require('promise.prototype.finally');
promiseFinally.shim(); // will be a no-op if not needed

var readFile = require('fs').readFile;
var httpRequest = require('request');
var util = require('util');

var f = require('../../lib/functional');
var ispn = require('../../lib/infinispan');
var u = require('../../lib/utils');
var protocols = require('../../lib/protocols');

exports.local = {port: 11222, host: '127.0.0.1'};

exports.cluster1 = {port: 11322, host: '127.0.0.1'};
exports.cluster2 = {port: 11332, host: '127.0.0.1'};
exports.cluster3 = {port: 11342, host: '127.0.0.1'};
exports.cluster = [exports.cluster1, exports.cluster2, exports.cluster3];
github Vizzuality / trase / frontend / scripts / index.jsx View on Github external
import { appActions } from 'app/app.register';
import App from 'app/app.component';
import toolLayersInitialState from 'react-components/tool-layers/tool-layers.initial-state';
import toolLayersSerialization from 'react-components/tool-layers/tool-layers.serializers';
import dashboardElementInitialState from 'react-components/dashboard-element/dashboard-element.initial-state';
import dashboardElementSerialization from 'react-components/dashboard-element/dashboard-element.serializers';
import nodesPanelInitialState from 'react-components/nodes-panel/nodes-panel.initial-state';
import nodesPanelSerialization from 'react-components/nodes-panel/nodes-panel.serializers';
import router from './router/router';
import { register, unregister } from './worker';

import 'styles/_base.scss';
import 'styles/_texts.scss';
import 'styles/_foundation.css';

promiseFinally.shim();

const sagaMiddleware = createSagaMiddleware();

// analytics middleware has to be after router.middleware
const middlewares = [thunk, sagaMiddleware, router.middleware, analyticsMiddleware];

window.liveSettings = TRANSIFEX_API_KEY && {
  api_key: TRANSIFEX_API_KEY,
  autocollect: true
};

// test for ie11 and googlebot
if (
  !(!window.ActiveXObject && 'ActiveXObject' in window) &&
  !/bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex/i.test(navigator.userAgent)
) {
github instagrambot / instabot.js / app / index.js View on Github external
/* eslint-disable import/no-extraneous-dependencies */

import '@/lib/instagram2';

import '@/styles/index.scss';
import 'ionicons/dist/css/ionicons.css';
import promiseFinally from 'promise.prototype.finally';

import { webFrame } from 'electron';
import React from 'react';
import { render } from 'react-dom';
import Instabot from '@/modules/Intabot';
import '../support/repl';

promiseFinally.shim();

webFrame.setVisualZoomLevelLimits(1, 1);
webFrame.setLayoutZoomLevelLimits(1, 1);

render(, document.getElementById('app'));
github cannc4 / Siren / src / index.js View on Github external
sceneStore,
  menubarStore,
  pulseStore,
  pathStore,
  rollStore,
  historyStore,
  globalStore,
  cellStore,
  nanoStore,
  debugStore
};

// For easier debugging
window.SIREN = stores;

promiseFinally.shim();
useStrict(false);

ReactDOM.render((
  
    
      <div>
        
        
      </div>
    
  
), document.getElementById('root'));
github resource-watch / resource-watch / pages / _app.js View on Github external
import { setHostname } from 'redactions/common';

// utils
import { containsString } from 'utils/string';

// constants
import {
  PAGES_WITHOUT_DASHBOARDS,
  PAGES_WITH_USER_COLLECTIONS,
  FULLSCREEN_PAGES
} from 'constants/app';

// global styles
import 'css/index.scss';

finallyShim.shim();

class RWApp extends App {
  static async getInitialProps({ Component, router, ctx }) {
    const { asPath } = router;
    const { req, store, query, isServer } = ctx;
    const pathname = req ? asPath : ctx.asPath;

    // sets app routes
    const url = { asPath, pathname, query };
    store.dispatch(setRouter(url));

    // sets hostname
    const hostname = isServer ? req.headers.host : window.origin;
    store.dispatch(setHostname(hostname));

    // sets user data coming from a request (server) or the store (client)
github Vizzuality / gfw / app / javascript / app / index.js View on Github external
import 'babel-polyfill';
// es6 shim for .finally() in promises
import finallyShim from 'promise.prototype.finally';
import React from 'react';
import { Provider } from 'react-redux';
import { HelmetProvider } from 'react-helmet-async';
import reducerRegistry from 'app/registry';
import { combineReducers } from 'redux';

import configureStore from './store';
import Root from './layouts/root';

finallyShim.shim();

const store = configureStore();

store.replaceReducer(combineReducers(reducerRegistry.getReducers()));

const App = () =&gt; (
  
    
      
    
  
);

export default App;
github wq / wq.app / packages / outbox / src / __tests__ / batch.js View on Github external
/**
 * @jest-environment ./packages/jest-env-jsdom-idb
 */

import store from '@wq/store';
import router from '@wq/router';
import outboxMod from '../outbox';
import model from '@wq/model';
import promiseFinally from 'promise.prototype.finally';

const ds = store.getStore('batch-test');
const outbox = outboxMod.getOutbox(ds);

promiseFinally.shim();

const mockApp = {
    plugins: {},
    hasPlugin: () => true,
    callPlugins(method, args) {
        Object.values(this.plugins).forEach(plugin =>
            plugin[method].apply(plugin, args)
        );
    }
};

const models = {},
    modelConf = {};

['item', 'itemtype'].forEach(name => {
    modelConf[name] = {
github brunch / brunch / lib / index.js View on Github external
'use strict';
require('micro-es7-shim');
require('promise.prototype.finally').shim();
const logger = require('loggy');
const BrunchError = require('./utils/error');
const checkLegacyNewSyntax = options => {
  const rawArgs = options.parent.rawArgs;
  const newArgs = rawArgs.slice(rawArgs.indexOf('new') + 1);
  const oldSyntax = !options.skeleton && newArgs.length === 2;
  if (!oldSyntax) return;

  throw new BrunchError('LEGACY_NEW_SYNTAX', {
    skeleton: newArgs[0],
    path: newArgs[1],
  });
};

const hasDebug = obj => {
  return obj && typeof obj === 'object' && obj.debug;
github chaitin / passionfruit / gui / src / vuex.js View on Github external
import Vuex from 'vuex'
import Vue from 'vue'
import axios from 'axios'

require('promise.prototype.finally').shim()

axios.defaults.baseURL = '/api'

Vue.use(Vuex)

function directSetter(...keys) {
  const result = {}
  keys.forEach(key => {
    result[key] = (state, val) => {
      state[key] = val
    }
  })
  return result
}

function directGetter(...keys) {