Ignore:
Timestamp:
11/25/21 22:08:24 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
8d391a1
Parents:
59329aa
Message:

primeNG components

Location:
trip-planner-front/node_modules/pify
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/node_modules/pify/index.js

    r59329aa re29cc2e  
    11'use strict';
    22
    3 var processFn = function (fn, P, opts) {
    4         return function () {
    5                 var that = this;
    6                 var args = new Array(arguments.length);
     3const processFn = (fn, options) => function (...args) {
     4        const P = options.promiseModule;
    75
    8                 for (var i = 0; i < arguments.length; i++) {
    9                         args[i] = arguments[i];
    10                 }
    11 
    12                 return new P(function (resolve, reject) {
    13                         args.push(function (err, result) {
    14                                 if (err) {
    15                                         reject(err);
    16                                 } else if (opts.multiArgs) {
    17                                         var results = new Array(arguments.length - 1);
    18 
    19                                         for (var i = 1; i < arguments.length; i++) {
    20                                                 results[i - 1] = arguments[i];
     6        return new P((resolve, reject) => {
     7                if (options.multiArgs) {
     8                        args.push((...result) => {
     9                                if (options.errorFirst) {
     10                                        if (result[0]) {
     11                                                reject(result);
     12                                        } else {
     13                                                result.shift();
     14                                                resolve(result);
    2115                                        }
    22 
    23                                         resolve(results);
    2416                                } else {
    2517                                        resolve(result);
    2618                                }
    2719                        });
     20                } else if (options.errorFirst) {
     21                        args.push((error, result) => {
     22                                if (error) {
     23                                        reject(error);
     24                                } else {
     25                                        resolve(result);
     26                                }
     27                        });
     28                } else {
     29                        args.push(resolve);
     30                }
    2831
    29                         fn.apply(that, args);
    30                 });
    31         };
     32                fn.apply(this, args);
     33        });
    3234};
    3335
    34 var pify = module.exports = function (obj, P, opts) {
    35         if (typeof P !== 'function') {
    36                 opts = P;
    37                 P = Promise;
     36module.exports = (input, options) => {
     37        options = Object.assign({
     38                exclude: [/.+(Sync|Stream)$/],
     39                errorFirst: true,
     40                promiseModule: Promise
     41        }, options);
     42
     43        const objType = typeof input;
     44        if (!(input !== null && (objType === 'object' || objType === 'function'))) {
     45                throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${input === null ? 'null' : objType}\``);
    3846        }
    3947
    40         opts = opts || {};
    41         opts.exclude = opts.exclude || [/.+Sync$/];
    42 
    43         var filter = function (key) {
    44                 var match = function (pattern) {
    45                         return typeof pattern === 'string' ? key === pattern : pattern.test(key);
    46                 };
    47 
    48                 return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
     48        const filter = key => {
     49                const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
     50                return options.include ? options.include.some(match) : !options.exclude.some(match);
    4951        };
    5052
    51         var ret = typeof obj === 'function' ? function () {
    52                 if (opts.excludeMain) {
    53                         return obj.apply(this, arguments);
    54                 }
     53        let ret;
     54        if (objType === 'function') {
     55                ret = function (...args) {
     56                        return options.excludeMain ? input(...args) : processFn(input, options).apply(this, args);
     57                };
     58        } else {
     59                ret = Object.create(Object.getPrototypeOf(input));
     60        }
    5561
    56                 return processFn(obj, P, opts).apply(this, arguments);
    57         } : {};
     62        for (const key in input) { // eslint-disable-line guard-for-in
     63                const property = input[key];
     64                ret[key] = typeof property === 'function' && filter(key) ? processFn(property, options) : property;
     65        }
    5866
    59         return Object.keys(obj).reduce(function (ret, key) {
    60                 var x = obj[key];
    61 
    62                 ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x;
    63 
    64                 return ret;
    65         }, ret);
     67        return ret;
    6668};
    67 
    68 pify.all = pify;
  • trip-planner-front/node_modules/pify/license

    r59329aa re29cc2e  
    1 The MIT License (MIT)
     1MIT License
    22
    33Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
    44
    5 Permission is hereby granted, free of charge, to any person obtaining a copy
    6 of this software and associated documentation files (the "Software"), to deal
    7 in the Software without restriction, including without limitation the rights
    8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    9 copies of the Software, and to permit persons to whom the Software is
    10 furnished to do so, subject to the following conditions:
     5Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
    116
    12 The above copyright notice and this permission notice shall be included in
    13 all copies or substantial portions of the Software.
     7The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    148
    15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    21 THE SOFTWARE.
     9THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • trip-planner-front/node_modules/pify/package.json

    r59329aa re29cc2e  
    11{
    2   "_args": [
    3     [
    4       "pify@2.3.0",
    5       "C:\\Users\\DELL\\Desktop\\bachelor-thesis\\trip-planner-front"
    6     ]
    7   ],
    8   "_development": true,
    9   "_from": "pify@2.3.0",
    10   "_id": "pify@2.3.0",
     2  "_from": "pify@^4.0.1",
     3  "_id": "pify@4.0.1",
    114  "_inBundle": false,
    12   "_integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
     5  "_integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
    136  "_location": "/pify",
    147  "_phantomChildren": {},
    158  "_requested": {
    16     "type": "version",
     9    "type": "range",
    1710    "registry": true,
    18     "raw": "pify@2.3.0",
     11    "raw": "pify@^4.0.1",
    1912    "name": "pify",
    2013    "escapedName": "pify",
    21     "rawSpec": "2.3.0",
     14    "rawSpec": "^4.0.1",
    2215    "saveSpec": null,
    23     "fetchSpec": "2.3.0"
     16    "fetchSpec": "^4.0.1"
    2417  },
    2518  "_requiredBy": [
    26     "/read-cache"
     19    "/del",
     20    "/less/make-dir"
    2721  ],
    28   "_resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
    29   "_spec": "2.3.0",
    30   "_where": "C:\\Users\\DELL\\Desktop\\bachelor-thesis\\trip-planner-front",
     22  "_resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
     23  "_shasum": "4b2cd25c50d598735c50292224fd8c6df41e3231",
     24  "_spec": "pify@^4.0.1",
     25  "_where": "C:\\Users\\DELL\\Desktop\\bachelor-thesis\\trip-planner-front\\node_modules\\less\\node_modules\\make-dir",
    3126  "author": {
    3227    "name": "Sindre Sorhus",
     
    3732    "url": "https://github.com/sindresorhus/pify/issues"
    3833  },
     34  "bundleDependencies": false,
     35  "deprecated": false,
    3936  "description": "Promisify a callback-style function",
    4037  "devDependencies": {
    41     "ava": "*",
    42     "pinkie-promise": "^1.0.0",
    43     "v8-natives": "0.0.2",
    44     "xo": "*"
     38    "ava": "^0.25.0",
     39    "pinkie-promise": "^2.0.0",
     40    "v8-natives": "^1.1.0",
     41    "xo": "^0.23.0"
    4542  },
    4643  "engines": {
    47     "node": ">=0.10.0"
     44    "node": ">=6"
    4845  },
    4946  "files": [
     
    5552    "promises",
    5653    "promisify",
     54    "all",
    5755    "denodify",
    5856    "denodeify",
     
    6967    "to",
    7068    "async",
    71     "es2015"
     69    "await",
     70    "es2015",
     71    "bluebird"
    7272  ],
    7373  "license": "MIT",
     
    7979  "scripts": {
    8080    "optimization-test": "node --allow-natives-syntax optimization-test.js",
    81     "test": "xo && ava && npm run optimization-test"
     81    "test": "xo && ava"
    8282  },
    83   "version": "2.3.0"
     83  "version": "4.0.1"
    8484}
  • trip-planner-front/node_modules/pify/readme.md

    r59329aa re29cc2e  
    22
    33> Promisify a callback-style function
     4
     5---
     6
     7<div align="center">
     8        <b>
     9                <a href="https://tidelift.com/subscription/pkg/npm-pify?utm_source=npm-pify&utm_medium=referral&utm_campaign=readme">Get professional support for 'pify' with a Tidelift subscription</a>
     10        </b>
     11        <br>
     12        <sub>
     13                Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
     14        </sub>
     15</div>
     16
     17---
    418
    519
     
    721
    822```
    9 $ npm install --save pify
     23$ npm install pify
    1024```
    1125
     
    1731const pify = require('pify');
    1832
    19 // promisify a single function
    20 
     33// Promisify a single function
    2134pify(fs.readFile)('package.json', 'utf8').then(data => {
    2235        console.log(JSON.parse(data).name);
     
    2437});
    2538
    26 // or promisify all methods in a module
    27 
     39// Promisify all methods in a module
    2840pify(fs).readFile('package.json', 'utf8').then(data => {
    2941        console.log(JSON.parse(data).name);
     
    3547## API
    3648
    37 ### pify(input, [promiseModule], [options])
     49### pify(input, [options])
    3850
    39 Returns a promise wrapped version of the supplied function or module.
     51Returns a `Promise` wrapped version of the supplied function or module.
    4052
    4153#### input
    4254
    43 Type: `function`, `object`
     55Type: `Function` `Object`
    4456
    4557Callback-style function or module whose methods you want to promisify.
    46 
    47 #### promiseModule
    48 
    49 Type: `function`
    50 
    51 Custom promise module to use instead of the native one.
    52 
    53 Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill.
    5458
    5559#### options
     
    5761##### multiArgs
    5862
    59 Type: `boolean` 
     63Type: `boolean`<br>
    6064Default: `false`
    6165
    62 By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument.
     66By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument. This also applies to rejections, where it returns an array of all the callback arguments, including the error.
    6367
    6468```js
     
    7377##### include
    7478
    75 Type: `array` of (`string`|`regex`)
     79Type: `string[]` `RegExp[]`
    7680
    7781Methods in a module to promisify. Remaining methods will be left untouched.
     
    7983##### exclude
    8084
    81 Type: `array` of (`string`|`regex`) 
    82 Default: `[/.+Sync$/]`
     85Type: `string[]` `RegExp[]`<br>
     86Default: `[/.+(Sync|Stream)$/]`
    8387
    8488Methods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default.
     
    8690##### excludeMain
    8791
    88 Type: `boolean` 
     92Type: `boolean`<br>
    8993Default: `false`
    9094
    91 By default, if given module is a function itself, this function will be promisified. Turn this option on if you want to promisify only methods of the module.
     95If given module is a function itself, it will be promisified. Turn this option on if you want to promisify only methods of the module.
    9296
    9397```js
     
    100104fn.method = (data, callback) => {
    101105        setImmediate(() => {
    102                 callback(data, null);
     106                callback(null, data);
    103107        });
    104108};
    105109
    106 // promisify methods but not fn()
     110// Promisify methods but not `fn()`
    107111const promiseFn = pify(fn, {excludeMain: true});
    108112
     
    114118```
    115119
     120##### errorFirst
     121
     122Type: `boolean`<br>
     123Default: `true`
     124
     125Whether the callback has an error as the first argument. You'll want to set this to `false` if you're dealing with an API that doesn't have an error as the first argument, like `fs.exists()`, some browser APIs, Chrome Extension APIs, etc.
     126
     127##### promiseModule
     128
     129Type: `Function`
     130
     131Custom promise module to use instead of the native one.
     132
     133Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill.
     134
     135
     136## Related
     137
     138- [p-event](https://github.com/sindresorhus/p-event) - Promisify an event by waiting for it to be emitted
     139- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
     140- [More…](https://github.com/sindresorhus/promise-fun)
     141
    116142
    117143## License
    118144
    119 MIT © [Sindre Sorhus](http://sindresorhus.com)
     145MIT © [Sindre Sorhus](https://sindresorhus.com)
Note: See TracChangeset for help on using the changeset viewer.