swell-js 3.20.0 → 3.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-1efbc7f9.js → api-3759aa14.js} +15 -15
- package/dist/api.js +15 -15
- package/dist/{attributes-65b29136.js → attributes-7a214d6b.js} +2 -2
- package/dist/attributes.js +3 -3
- package/dist/{cache-e20666f1.js → cache-751d89b1.js} +1 -1
- package/dist/cache.js +2 -2
- package/dist/{card-68720a8a.js → card-91071403.js} +1 -1
- package/dist/card.js +2 -2
- package/dist/{cart-4f70ad5f.js → cart-ff3e3ef6.js} +2 -2
- package/dist/cart.js +5 -5
- package/dist/{categories-231942ca.js → categories-8f6a4584.js} +2 -2
- package/dist/categories.js +3 -3
- package/dist/{content-8711bc91.js → content-0afdcb05.js} +1 -1
- package/dist/content.js +3 -3
- package/dist/{cookie-105be66f.js → cookie-b78058af.js} +1 -1
- package/dist/cookie.js +2 -2
- package/dist/{currency-6044dae3.js → currency-842f76f2.js} +2 -2
- package/dist/currency.js +3 -3
- package/dist/{index-42f745bb.js → index-47c8a8e3.js} +47 -10
- package/dist/{index-cde4db96.js → index-512fc30d.js} +285 -3
- package/dist/index.js +15 -15
- package/dist/{locale-95671e4d.js → locale-4391bcf3.js} +2 -2
- package/dist/locale.js +3 -3
- package/dist/payment.js +7 -7
- package/dist/{products-103d12fc.js → products-7f2fbc3e.js} +3 -3
- package/dist/products.js +4 -4
- package/dist/{settings-ae65722d.js → settings-937b96f1.js} +1 -1
- package/dist/settings.js +2 -2
- package/dist/{subscriptions-64ab09c1.js → subscriptions-8044a530.js} +3 -3
- package/dist/subscriptions.js +5 -5
- package/dist/swell.cjs.js +329 -10
- package/dist/swell.cjs.js.map +1 -1
- package/dist/swell.umd.min.js +422 -99
- package/dist/swell.umd.min.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/types/billing/camel.d.ts +37 -0
- package/types/billing/index.d.ts +29 -0
- package/types/billing/snake.d.ts +59 -0
- package/types/card/snake.d.ts +3 -2
- package/types/cart/camel.d.ts +13 -1
- package/types/cart/index.d.ts +8 -4
- package/types/cart/snake.d.ts +71 -12
- package/types/coupon/camel.d.ts +6 -0
- package/types/coupon/index.d.ts +4 -0
- package/types/coupon/snake.d.ts +15 -0
- package/types/discount/camel.d.ts +6 -0
- package/types/discount/index.d.ts +4 -0
- package/types/discount/snake.d.ts +12 -0
- package/types/index.d.ts +3 -2
- package/types/invoice/snake.d.ts +7 -5
- package/types/order/camel.d.ts +11 -1
- package/types/order/index.d.ts +7 -4
- package/types/order/snake.d.ts +80 -22
- package/types/payment/index.d.ts +53 -26
- package/types/payment/snake.d.ts +4 -2
- package/types/product/camel.d.ts +4 -0
- package/types/product/index.d.ts +9 -8
- package/types/product/snake.d.ts +18 -17
- package/types/promotion/camel.d.ts +6 -0
- package/types/promotion/index.d.ts +4 -0
- package/types/promotion/snake.d.ts +20 -0
- package/types/purchase_link/camel.d.ts +14 -0
- package/types/purchase_link/index.d.ts +11 -0
- package/types/purchase_link/snake.d.ts +26 -0
- package/types/refund/camel.d.ts +6 -0
- package/types/refund/index.d.ts +4 -0
- package/types/refund/snake.d.ts +30 -0
- package/types/shipment_rating/camel.d.ts +10 -0
- package/types/shipment_rating/index.d.ts +5 -0
- package/types/shipment_rating/snake.d.ts +14 -0
- package/types/subscription/camel.d.ts +5 -1
- package/types/subscription/index.d.ts +4 -3
- package/types/subscription/snake.d.ts +36 -24
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { c as cardApi } from './card-
|
|
2
|
-
import { g as getCookie, s as setCookie } from './cookie-
|
|
3
|
-
import { c as cacheApi } from './cache-
|
|
4
|
-
import { m as methods$1 } from './cart-
|
|
1
|
+
import { c as cardApi } from './card-91071403.js';
|
|
2
|
+
import { g as getCookie, s as setCookie } from './cookie-b78058af.js';
|
|
3
|
+
import { c as cacheApi } from './cache-751d89b1.js';
|
|
4
|
+
import { m as methods$1 } from './cart-ff3e3ef6.js';
|
|
5
5
|
import { m as methods$2 } from './account-328cc590.js';
|
|
6
|
-
import { m as methods$3 } from './products-
|
|
7
|
-
import { m as methods$4 } from './categories-
|
|
8
|
-
import { m as methods$5 } from './attributes-
|
|
9
|
-
import { m as methods$6 } from './subscriptions-
|
|
10
|
-
import { d as defaultMethods, n as trimEnd,
|
|
11
|
-
import { m as methods$7 } from './content-
|
|
12
|
-
import { m as methods$8 } from './settings-
|
|
13
|
-
import { P as PaymentController } from './index-
|
|
14
|
-
import { m as methods$9 } from './locale-
|
|
15
|
-
import { m as methods$a } from './currency-
|
|
6
|
+
import { m as methods$3 } from './products-7f2fbc3e.js';
|
|
7
|
+
import { m as methods$4 } from './categories-8f6a4584.js';
|
|
8
|
+
import { m as methods$5 } from './attributes-7a214d6b.js';
|
|
9
|
+
import { m as methods$6 } from './subscriptions-8044a530.js';
|
|
10
|
+
import { d as defaultMethods, n as trimEnd, K as utils, l as trimStart, k as trimBoth, j as toSnake, o as stringifyQuery, E as base64Encode, t as toCamel, e as setOptions } from './index-512fc30d.js';
|
|
11
|
+
import { m as methods$7 } from './content-0afdcb05.js';
|
|
12
|
+
import { m as methods$8 } from './settings-937b96f1.js';
|
|
13
|
+
import { P as PaymentController } from './index-47c8a8e3.js';
|
|
14
|
+
import { m as methods$9 } from './locale-4391bcf3.js';
|
|
15
|
+
import { m as methods$a } from './currency-842f76f2.js';
|
|
16
16
|
|
|
17
17
|
function methods(request) {
|
|
18
18
|
const { get, list } = defaultMethods(request, '/invoices', ['list', 'get']);
|
|
@@ -34,7 +34,7 @@ const options = {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const api = {
|
|
37
|
-
version: '3.20.
|
|
37
|
+
version: '3.20.2',
|
|
38
38
|
options,
|
|
39
39
|
request,
|
|
40
40
|
|
package/dist/api.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { a as default } from './api-
|
|
2
|
-
import './card-
|
|
3
|
-
import './index-
|
|
1
|
+
export { a as default } from './api-3759aa14.js';
|
|
2
|
+
import './card-91071403.js';
|
|
3
|
+
import './index-512fc30d.js';
|
|
4
4
|
import 'qs';
|
|
5
5
|
import 'deepmerge';
|
|
6
6
|
import 'fast-case';
|
|
7
|
-
import './cookie-
|
|
8
|
-
import './cache-
|
|
9
|
-
import './cart-
|
|
10
|
-
import './products-
|
|
11
|
-
import './attributes-
|
|
7
|
+
import './cookie-b78058af.js';
|
|
8
|
+
import './cache-751d89b1.js';
|
|
9
|
+
import './cart-ff3e3ef6.js';
|
|
10
|
+
import './products-7f2fbc3e.js';
|
|
11
|
+
import './attributes-7a214d6b.js';
|
|
12
12
|
import './account-328cc590.js';
|
|
13
|
-
import './categories-
|
|
14
|
-
import './subscriptions-
|
|
15
|
-
import './content-
|
|
16
|
-
import './settings-
|
|
17
|
-
import './index-
|
|
18
|
-
import './locale-
|
|
19
|
-
import './currency-
|
|
13
|
+
import './categories-8f6a4584.js';
|
|
14
|
+
import './subscriptions-8044a530.js';
|
|
15
|
+
import './content-0afdcb05.js';
|
|
16
|
+
import './settings-937b96f1.js';
|
|
17
|
+
import './index-47c8a8e3.js';
|
|
18
|
+
import './locale-4391bcf3.js';
|
|
19
|
+
import './currency-842f76f2.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as defaultMethods } from './index-
|
|
2
|
-
import { c as cacheApi } from './cache-
|
|
1
|
+
import { d as defaultMethods } from './index-512fc30d.js';
|
|
2
|
+
import { c as cacheApi } from './cache-751d89b1.js';
|
|
3
3
|
|
|
4
4
|
function methods(request) {
|
|
5
5
|
const { get, list } = defaultMethods(request, '/attributes', ['list', 'get']);
|
package/dist/attributes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { m as default } from './attributes-
|
|
2
|
-
import './index-
|
|
1
|
+
export { m as default } from './attributes-7a214d6b.js';
|
|
2
|
+
import './index-512fc30d.js';
|
|
3
3
|
import 'qs';
|
|
4
4
|
import 'deepmerge';
|
|
5
5
|
import 'fast-case';
|
|
6
|
-
import './cache-
|
|
6
|
+
import './cache-751d89b1.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as set, g as get, m as merge, t as toCamel, i as toCamelPath, h as getOptions } from './index-
|
|
1
|
+
import { s as set, g as get, m as merge, t as toCamel, i as toCamelPath, h as getOptions } from './index-512fc30d.js';
|
|
2
2
|
|
|
3
3
|
const RECORD_TIMEOUT = 5000;
|
|
4
4
|
|
package/dist/cache.js
CHANGED
package/dist/card.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'qs';
|
|
2
|
-
import { b as cloneDeep } from './index-
|
|
2
|
+
import { b as cloneDeep } from './index-512fc30d.js';
|
|
3
3
|
import 'deepmerge';
|
|
4
4
|
import 'fast-case';
|
|
5
|
-
import { c as cleanProductOptions } from './products-
|
|
5
|
+
import { c as cleanProductOptions } from './products-7f2fbc3e.js';
|
|
6
6
|
|
|
7
7
|
function methods(request, options) {
|
|
8
8
|
return {
|
package/dist/cart.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { m as default } from './cart-
|
|
1
|
+
export { m as default } from './cart-ff3e3ef6.js';
|
|
2
2
|
import 'qs';
|
|
3
|
-
import './index-
|
|
3
|
+
import './index-512fc30d.js';
|
|
4
4
|
import 'deepmerge';
|
|
5
5
|
import 'fast-case';
|
|
6
|
-
import './products-
|
|
7
|
-
import './cache-
|
|
8
|
-
import './attributes-
|
|
6
|
+
import './products-7f2fbc3e.js';
|
|
7
|
+
import './cache-751d89b1.js';
|
|
8
|
+
import './attributes-7a214d6b.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as defaultMethods } from './index-
|
|
2
|
-
import { c as cacheApi } from './cache-
|
|
1
|
+
import { d as defaultMethods } from './index-512fc30d.js';
|
|
2
|
+
import { c as cacheApi } from './cache-751d89b1.js';
|
|
3
3
|
|
|
4
4
|
function methods(request) {
|
|
5
5
|
const { get, list } = defaultMethods(request, '/categories', ['list', 'get']);
|
package/dist/categories.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { m as default } from './categories-
|
|
2
|
-
import './index-
|
|
1
|
+
export { m as default } from './categories-8f6a4584.js';
|
|
2
|
+
import './index-512fc30d.js';
|
|
3
3
|
import 'qs';
|
|
4
4
|
import 'deepmerge';
|
|
5
5
|
import 'fast-case';
|
|
6
|
-
import './cache-
|
|
6
|
+
import './cache-751d89b1.js';
|
package/dist/content.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { m as default } from './content-
|
|
2
|
-
import './cache-
|
|
3
|
-
import './index-
|
|
1
|
+
export { m as default } from './content-0afdcb05.js';
|
|
2
|
+
import './cache-751d89b1.js';
|
|
3
|
+
import './index-512fc30d.js';
|
|
4
4
|
import 'qs';
|
|
5
5
|
import 'deepmerge';
|
|
6
6
|
import 'fast-case';
|
package/dist/cookie.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'qs';
|
|
2
|
-
import { f as find, g as get, r as round } from './index-
|
|
2
|
+
import { f as find, g as get, r as round } from './index-512fc30d.js';
|
|
3
3
|
import 'deepmerge';
|
|
4
4
|
import 'fast-case';
|
|
5
|
-
import { g as getCookie, s as setCookie } from './cookie-
|
|
5
|
+
import { g as getCookie, s as setCookie } from './cookie-b78058af.js';
|
|
6
6
|
|
|
7
7
|
const FORMATTERS = {};
|
|
8
8
|
|
package/dist/currency.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { m as default } from './currency-
|
|
1
|
+
export { m as default } from './currency-842f76f2.js';
|
|
2
2
|
import 'qs';
|
|
3
|
-
import './index-
|
|
3
|
+
import './index-512fc30d.js';
|
|
4
4
|
import 'deepmerge';
|
|
5
5
|
import 'fast-case';
|
|
6
|
-
import './cookie-
|
|
6
|
+
import './cookie-b78058af.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as methods } from './cart-
|
|
2
|
-
import { m as methods$1 } from './settings-
|
|
3
|
-
import {
|
|
1
|
+
import { m as methods } from './cart-ff3e3ef6.js';
|
|
2
|
+
import { m as methods$1 } from './settings-937b96f1.js';
|
|
3
|
+
import { v as isFunction, w as isObject, I as loadScript, j as toSnake, b as cloneDeep, g as get, F as vaultRequest, p as pick, y as toLower, A as isEmpty, C as map, x as toNumber, D as reduce, J as isLiveMode, G as getLocationParams, H as removeUrlParams, t as toCamel } from './index-512fc30d.js';
|
|
4
4
|
import 'qs';
|
|
5
5
|
import 'deepmerge';
|
|
6
6
|
import 'fast-case';
|
|
@@ -38,7 +38,7 @@ async function loadPaypal(params) {
|
|
|
38
38
|
if (!window.paypal) {
|
|
39
39
|
await loadScript(
|
|
40
40
|
'paypal-sdk',
|
|
41
|
-
`https://www.paypal.com/sdk/js?client-id=${params.client_id}&merchant-id=${params.merchant_id}&intent=authorize&commit=false`,
|
|
41
|
+
`https://www.paypal.com/sdk/js?currency=${params.currency}&client-id=${params.client_id}&merchant-id=${params.merchant_id}&intent=authorize&commit=false`,
|
|
42
42
|
{
|
|
43
43
|
'data-partner-attribution-id': 'SwellCommerce_SP',
|
|
44
44
|
},
|
|
@@ -163,6 +163,7 @@ class Payment {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
async loadScripts(scripts) {
|
|
166
|
+
await this._populateScriptsParams(scripts);
|
|
166
167
|
await loadScripts(scripts);
|
|
167
168
|
}
|
|
168
169
|
|
|
@@ -173,6 +174,14 @@ class Payment {
|
|
|
173
174
|
throw new Error('Cart not found');
|
|
174
175
|
}
|
|
175
176
|
|
|
177
|
+
if (!cart.settings) {
|
|
178
|
+
const settings = await this.getSettings();
|
|
179
|
+
|
|
180
|
+
cart.settings = {
|
|
181
|
+
...settings.store,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
176
185
|
return toSnake(cart);
|
|
177
186
|
}
|
|
178
187
|
|
|
@@ -248,6 +257,29 @@ class Payment {
|
|
|
248
257
|
|
|
249
258
|
return response;
|
|
250
259
|
}
|
|
260
|
+
|
|
261
|
+
async _populateScriptsParams(scripts = []) {
|
|
262
|
+
for (const script of scripts) {
|
|
263
|
+
await this._populateScriptWithCartParams(script);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
async _populateScriptWithCartParams(script) {
|
|
268
|
+
const cartParams = get(script, 'params.cart');
|
|
269
|
+
|
|
270
|
+
if (!cartParams) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const cart = await this.getCart();
|
|
275
|
+
|
|
276
|
+
script.params = {
|
|
277
|
+
...script.params,
|
|
278
|
+
...pick(cart, cartParams),
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
delete script.params.cart;
|
|
282
|
+
}
|
|
251
283
|
}
|
|
252
284
|
|
|
253
285
|
// https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts
|
|
@@ -964,13 +996,9 @@ class StripeKlarnaPayment extends Payment {
|
|
|
964
996
|
|
|
965
997
|
async tokenize() {
|
|
966
998
|
const cart = await this.getCart();
|
|
967
|
-
const settings = await this.getSettings();
|
|
968
999
|
const { source, error: sourceError } = await createKlarnaSource(
|
|
969
1000
|
this.stripe,
|
|
970
|
-
|
|
971
|
-
...cart,
|
|
972
|
-
settings: settings.store,
|
|
973
|
-
},
|
|
1001
|
+
cart,
|
|
974
1002
|
);
|
|
975
1003
|
|
|
976
1004
|
if (sourceError) {
|
|
@@ -2353,7 +2381,16 @@ class PaypalDirectPayment extends Payment {
|
|
|
2353
2381
|
get scripts() {
|
|
2354
2382
|
const { client_id, merchant_id } = this.method;
|
|
2355
2383
|
|
|
2356
|
-
return [
|
|
2384
|
+
return [
|
|
2385
|
+
{
|
|
2386
|
+
id: 'paypal-sdk',
|
|
2387
|
+
params: {
|
|
2388
|
+
client_id,
|
|
2389
|
+
merchant_id,
|
|
2390
|
+
cart: ['currency'],
|
|
2391
|
+
},
|
|
2392
|
+
},
|
|
2393
|
+
];
|
|
2357
2394
|
}
|
|
2358
2395
|
|
|
2359
2396
|
get paypal() {
|
|
@@ -3174,7 +3174,7 @@ function toInteger(value) {
|
|
|
3174
3174
|
}
|
|
3175
3175
|
|
|
3176
3176
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
3177
|
-
var nativeMax = Math.max;
|
|
3177
|
+
var nativeMax$1 = Math.max;
|
|
3178
3178
|
|
|
3179
3179
|
/**
|
|
3180
3180
|
* This method is like `_.find` except that it returns the index of the first
|
|
@@ -3218,7 +3218,7 @@ function findIndex(array, predicate, fromIndex) {
|
|
|
3218
3218
|
}
|
|
3219
3219
|
var index = fromIndex == null ? 0 : toInteger(fromIndex);
|
|
3220
3220
|
if (index < 0) {
|
|
3221
|
-
index = nativeMax(length + index, 0);
|
|
3221
|
+
index = nativeMax$1(length + index, 0);
|
|
3222
3222
|
}
|
|
3223
3223
|
return baseFindIndex(array, baseIteratee(predicate), index);
|
|
3224
3224
|
}
|
|
@@ -3313,6 +3313,287 @@ function createRound(methodName) {
|
|
|
3313
3313
|
*/
|
|
3314
3314
|
var round = createRound('round');
|
|
3315
3315
|
|
|
3316
|
+
/**
|
|
3317
|
+
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
|
3318
|
+
*
|
|
3319
|
+
* @private
|
|
3320
|
+
* @param {Object} object The source object.
|
|
3321
|
+
* @param {string[]} paths The property paths to pick.
|
|
3322
|
+
* @param {Function} predicate The function invoked per property.
|
|
3323
|
+
* @returns {Object} Returns the new object.
|
|
3324
|
+
*/
|
|
3325
|
+
function basePickBy(object, paths, predicate) {
|
|
3326
|
+
var index = -1,
|
|
3327
|
+
length = paths.length,
|
|
3328
|
+
result = {};
|
|
3329
|
+
|
|
3330
|
+
while (++index < length) {
|
|
3331
|
+
var path = paths[index],
|
|
3332
|
+
value = baseGet(object, path);
|
|
3333
|
+
|
|
3334
|
+
if (predicate(value, path)) {
|
|
3335
|
+
baseSet(result, castPath(path, object), value);
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
return result;
|
|
3339
|
+
}
|
|
3340
|
+
|
|
3341
|
+
/**
|
|
3342
|
+
* The base implementation of `_.pick` without support for individual
|
|
3343
|
+
* property identifiers.
|
|
3344
|
+
*
|
|
3345
|
+
* @private
|
|
3346
|
+
* @param {Object} object The source object.
|
|
3347
|
+
* @param {string[]} paths The property paths to pick.
|
|
3348
|
+
* @returns {Object} Returns the new object.
|
|
3349
|
+
*/
|
|
3350
|
+
function basePick(object, paths) {
|
|
3351
|
+
return basePickBy(object, paths, function(value, path) {
|
|
3352
|
+
return hasIn(object, path);
|
|
3353
|
+
});
|
|
3354
|
+
}
|
|
3355
|
+
|
|
3356
|
+
/** Built-in value references. */
|
|
3357
|
+
var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
|
|
3358
|
+
|
|
3359
|
+
/**
|
|
3360
|
+
* Checks if `value` is a flattenable `arguments` object or array.
|
|
3361
|
+
*
|
|
3362
|
+
* @private
|
|
3363
|
+
* @param {*} value The value to check.
|
|
3364
|
+
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
|
3365
|
+
*/
|
|
3366
|
+
function isFlattenable(value) {
|
|
3367
|
+
return isArray(value) || isArguments(value) ||
|
|
3368
|
+
!!(spreadableSymbol && value && value[spreadableSymbol]);
|
|
3369
|
+
}
|
|
3370
|
+
|
|
3371
|
+
/**
|
|
3372
|
+
* The base implementation of `_.flatten` with support for restricting flattening.
|
|
3373
|
+
*
|
|
3374
|
+
* @private
|
|
3375
|
+
* @param {Array} array The array to flatten.
|
|
3376
|
+
* @param {number} depth The maximum recursion depth.
|
|
3377
|
+
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
|
3378
|
+
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
|
3379
|
+
* @param {Array} [result=[]] The initial result value.
|
|
3380
|
+
* @returns {Array} Returns the new flattened array.
|
|
3381
|
+
*/
|
|
3382
|
+
function baseFlatten(array, depth, predicate, isStrict, result) {
|
|
3383
|
+
var index = -1,
|
|
3384
|
+
length = array.length;
|
|
3385
|
+
|
|
3386
|
+
predicate || (predicate = isFlattenable);
|
|
3387
|
+
result || (result = []);
|
|
3388
|
+
|
|
3389
|
+
while (++index < length) {
|
|
3390
|
+
var value = array[index];
|
|
3391
|
+
if (depth > 0 && predicate(value)) {
|
|
3392
|
+
if (depth > 1) {
|
|
3393
|
+
// Recursively flatten arrays (susceptible to call stack limits).
|
|
3394
|
+
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
|
3395
|
+
} else {
|
|
3396
|
+
arrayPush(result, value);
|
|
3397
|
+
}
|
|
3398
|
+
} else if (!isStrict) {
|
|
3399
|
+
result[result.length] = value;
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
return result;
|
|
3403
|
+
}
|
|
3404
|
+
|
|
3405
|
+
/**
|
|
3406
|
+
* Flattens `array` a single level deep.
|
|
3407
|
+
*
|
|
3408
|
+
* @static
|
|
3409
|
+
* @memberOf _
|
|
3410
|
+
* @since 0.1.0
|
|
3411
|
+
* @category Array
|
|
3412
|
+
* @param {Array} array The array to flatten.
|
|
3413
|
+
* @returns {Array} Returns the new flattened array.
|
|
3414
|
+
* @example
|
|
3415
|
+
*
|
|
3416
|
+
* _.flatten([1, [2, [3, [4]], 5]]);
|
|
3417
|
+
* // => [1, 2, [3, [4]], 5]
|
|
3418
|
+
*/
|
|
3419
|
+
function flatten(array) {
|
|
3420
|
+
var length = array == null ? 0 : array.length;
|
|
3421
|
+
return length ? baseFlatten(array, 1) : [];
|
|
3422
|
+
}
|
|
3423
|
+
|
|
3424
|
+
/**
|
|
3425
|
+
* A faster alternative to `Function#apply`, this function invokes `func`
|
|
3426
|
+
* with the `this` binding of `thisArg` and the arguments of `args`.
|
|
3427
|
+
*
|
|
3428
|
+
* @private
|
|
3429
|
+
* @param {Function} func The function to invoke.
|
|
3430
|
+
* @param {*} thisArg The `this` binding of `func`.
|
|
3431
|
+
* @param {Array} args The arguments to invoke `func` with.
|
|
3432
|
+
* @returns {*} Returns the result of `func`.
|
|
3433
|
+
*/
|
|
3434
|
+
function apply(func, thisArg, args) {
|
|
3435
|
+
switch (args.length) {
|
|
3436
|
+
case 0: return func.call(thisArg);
|
|
3437
|
+
case 1: return func.call(thisArg, args[0]);
|
|
3438
|
+
case 2: return func.call(thisArg, args[0], args[1]);
|
|
3439
|
+
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
|
3440
|
+
}
|
|
3441
|
+
return func.apply(thisArg, args);
|
|
3442
|
+
}
|
|
3443
|
+
|
|
3444
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
3445
|
+
var nativeMax = Math.max;
|
|
3446
|
+
|
|
3447
|
+
/**
|
|
3448
|
+
* A specialized version of `baseRest` which transforms the rest array.
|
|
3449
|
+
*
|
|
3450
|
+
* @private
|
|
3451
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
3452
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
3453
|
+
* @param {Function} transform The rest array transform.
|
|
3454
|
+
* @returns {Function} Returns the new function.
|
|
3455
|
+
*/
|
|
3456
|
+
function overRest(func, start, transform) {
|
|
3457
|
+
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
|
3458
|
+
return function() {
|
|
3459
|
+
var args = arguments,
|
|
3460
|
+
index = -1,
|
|
3461
|
+
length = nativeMax(args.length - start, 0),
|
|
3462
|
+
array = Array(length);
|
|
3463
|
+
|
|
3464
|
+
while (++index < length) {
|
|
3465
|
+
array[index] = args[start + index];
|
|
3466
|
+
}
|
|
3467
|
+
index = -1;
|
|
3468
|
+
var otherArgs = Array(start + 1);
|
|
3469
|
+
while (++index < start) {
|
|
3470
|
+
otherArgs[index] = args[index];
|
|
3471
|
+
}
|
|
3472
|
+
otherArgs[start] = transform(array);
|
|
3473
|
+
return apply(func, this, otherArgs);
|
|
3474
|
+
};
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3477
|
+
/**
|
|
3478
|
+
* Creates a function that returns `value`.
|
|
3479
|
+
*
|
|
3480
|
+
* @static
|
|
3481
|
+
* @memberOf _
|
|
3482
|
+
* @since 2.4.0
|
|
3483
|
+
* @category Util
|
|
3484
|
+
* @param {*} value The value to return from the new function.
|
|
3485
|
+
* @returns {Function} Returns the new constant function.
|
|
3486
|
+
* @example
|
|
3487
|
+
*
|
|
3488
|
+
* var objects = _.times(2, _.constant({ 'a': 1 }));
|
|
3489
|
+
*
|
|
3490
|
+
* console.log(objects);
|
|
3491
|
+
* // => [{ 'a': 1 }, { 'a': 1 }]
|
|
3492
|
+
*
|
|
3493
|
+
* console.log(objects[0] === objects[1]);
|
|
3494
|
+
* // => true
|
|
3495
|
+
*/
|
|
3496
|
+
function constant(value) {
|
|
3497
|
+
return function() {
|
|
3498
|
+
return value;
|
|
3499
|
+
};
|
|
3500
|
+
}
|
|
3501
|
+
|
|
3502
|
+
/**
|
|
3503
|
+
* The base implementation of `setToString` without support for hot loop shorting.
|
|
3504
|
+
*
|
|
3505
|
+
* @private
|
|
3506
|
+
* @param {Function} func The function to modify.
|
|
3507
|
+
* @param {Function} string The `toString` result.
|
|
3508
|
+
* @returns {Function} Returns `func`.
|
|
3509
|
+
*/
|
|
3510
|
+
var baseSetToString = !defineProperty ? identity : function(func, string) {
|
|
3511
|
+
return defineProperty(func, 'toString', {
|
|
3512
|
+
'configurable': true,
|
|
3513
|
+
'enumerable': false,
|
|
3514
|
+
'value': constant(string),
|
|
3515
|
+
'writable': true
|
|
3516
|
+
});
|
|
3517
|
+
};
|
|
3518
|
+
|
|
3519
|
+
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
|
3520
|
+
var HOT_COUNT = 800,
|
|
3521
|
+
HOT_SPAN = 16;
|
|
3522
|
+
|
|
3523
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
3524
|
+
var nativeNow = Date.now;
|
|
3525
|
+
|
|
3526
|
+
/**
|
|
3527
|
+
* Creates a function that'll short out and invoke `identity` instead
|
|
3528
|
+
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
|
|
3529
|
+
* milliseconds.
|
|
3530
|
+
*
|
|
3531
|
+
* @private
|
|
3532
|
+
* @param {Function} func The function to restrict.
|
|
3533
|
+
* @returns {Function} Returns the new shortable function.
|
|
3534
|
+
*/
|
|
3535
|
+
function shortOut(func) {
|
|
3536
|
+
var count = 0,
|
|
3537
|
+
lastCalled = 0;
|
|
3538
|
+
|
|
3539
|
+
return function() {
|
|
3540
|
+
var stamp = nativeNow(),
|
|
3541
|
+
remaining = HOT_SPAN - (stamp - lastCalled);
|
|
3542
|
+
|
|
3543
|
+
lastCalled = stamp;
|
|
3544
|
+
if (remaining > 0) {
|
|
3545
|
+
if (++count >= HOT_COUNT) {
|
|
3546
|
+
return arguments[0];
|
|
3547
|
+
}
|
|
3548
|
+
} else {
|
|
3549
|
+
count = 0;
|
|
3550
|
+
}
|
|
3551
|
+
return func.apply(undefined, arguments);
|
|
3552
|
+
};
|
|
3553
|
+
}
|
|
3554
|
+
|
|
3555
|
+
/**
|
|
3556
|
+
* Sets the `toString` method of `func` to return `string`.
|
|
3557
|
+
*
|
|
3558
|
+
* @private
|
|
3559
|
+
* @param {Function} func The function to modify.
|
|
3560
|
+
* @param {Function} string The `toString` result.
|
|
3561
|
+
* @returns {Function} Returns `func`.
|
|
3562
|
+
*/
|
|
3563
|
+
var setToString = shortOut(baseSetToString);
|
|
3564
|
+
|
|
3565
|
+
/**
|
|
3566
|
+
* A specialized version of `baseRest` which flattens the rest array.
|
|
3567
|
+
*
|
|
3568
|
+
* @private
|
|
3569
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
3570
|
+
* @returns {Function} Returns the new function.
|
|
3571
|
+
*/
|
|
3572
|
+
function flatRest(func) {
|
|
3573
|
+
return setToString(overRest(func, undefined, flatten), func + '');
|
|
3574
|
+
}
|
|
3575
|
+
|
|
3576
|
+
/**
|
|
3577
|
+
* Creates an object composed of the picked `object` properties.
|
|
3578
|
+
*
|
|
3579
|
+
* @static
|
|
3580
|
+
* @since 0.1.0
|
|
3581
|
+
* @memberOf _
|
|
3582
|
+
* @category Object
|
|
3583
|
+
* @param {Object} object The source object.
|
|
3584
|
+
* @param {...(string|string[])} [paths] The property paths to pick.
|
|
3585
|
+
* @returns {Object} Returns the new object.
|
|
3586
|
+
* @example
|
|
3587
|
+
*
|
|
3588
|
+
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
|
3589
|
+
*
|
|
3590
|
+
* _.pick(object, ['a', 'c']);
|
|
3591
|
+
* // => { 'a': 1, 'c': 3 }
|
|
3592
|
+
*/
|
|
3593
|
+
var pick = flatRest(function(object, paths) {
|
|
3594
|
+
return object == null ? {} : basePick(object, paths);
|
|
3595
|
+
});
|
|
3596
|
+
|
|
3316
3597
|
/**
|
|
3317
3598
|
* A specialized version of `_.forEach` for arrays without support for
|
|
3318
3599
|
* iteratee shorthands.
|
|
@@ -4435,6 +4716,7 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
4435
4716
|
uniq: uniq,
|
|
4436
4717
|
find: find,
|
|
4437
4718
|
round: round,
|
|
4719
|
+
pick: pick,
|
|
4438
4720
|
findIndex: findIndex,
|
|
4439
4721
|
camelCase: camelCase,
|
|
4440
4722
|
cloneDeep: cloneDeep,
|
|
@@ -4466,4 +4748,4 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
4466
4748
|
isLiveMode: isLiveMode
|
|
4467
4749
|
});
|
|
4468
4750
|
|
|
4469
|
-
export {
|
|
4751
|
+
export { isEmpty as A, snakeCase as B, map as C, reduce as D, base64Encode as E, vaultRequest as F, getLocationParams as G, removeUrlParams as H, loadScript as I, isLiveMode as J, utils as K, findIndex as a, cloneDeep as b, camelCase as c, defaultMethods as d, setOptions as e, find as f, get as g, getOptions as h, toCamelPath as i, toSnake as j, trimBoth as k, trimStart as l, merge as m, trimEnd as n, stringifyQuery as o, pick as p, isServer as q, round as r, set as s, toCamel as t, uniq as u, isFunction as v, isObject as w, toNumber as x, toLower as y, isEqual as z };
|