You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
12 KiB
27 lines
12 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("exports ../arcade/deepClone ../arcade/executionError ../arcade/ImmutableArray ./languageUtils ../core/promiseUtils".split(" "),function(v,w,g,z,f,q){function x(k){function n(b,e,d){if(b instanceof z)return b.toArray();if(f.isArray(b))return b;throw new g.ArcadeExecutionError(e,g.ExecutionErrorCodes.InvalidParameter,d);}function p(b,e){var d=b.length,c=Math.floor(d/2);if(0===d)return[];if(1===d)return[b[0]];var a=p(b.slice(0,c),e);b=p(b.slice(c,d),e);for(d=[];0<a.length||0<b.length;)0<a.length&& |
|
0<b.length?(c=e(a[0],b[0]),isNaN(c)&&(c=0),0>=c?(d.push(a[0]),a=a.slice(1)):(d.push(b[0]),b=b.slice(1))):0<a.length?(d.push(a[0]),a=a.slice(1)):0<b.length&&(d.push(b[0]),b=b.slice(1));return d}async function t(b,e){const d=b.length,c=Math.floor(d/2);if(0===d)return[];if(1===d)return[b[0]];b=[await t(b.slice(0,c),e),await t(b.slice(c,d),e)];return r(b[0],b[1],e,[])}async function r(b,e,d,c){if(0<b.length||0<e.length){if(0<b.length&&0<e.length){let a=await d(b[0],e[0]);isNaN(a)&&(a=1);0>=a?(c.push(b[0]), |
|
b=b.slice(1)):(c.push(e[0]),e=e.slice(1));return r(b,e,d,c)}if(0<b.length)return c.push(b[0]),b=b.slice(1),r(b,e,d,c);c.push(e[0]);e=e.slice(1);return r(b,e,d,c)}return c}function y(b,e,d,c){f.pcCheck(d,1,2,b,e);let a=d[0];f.isImmutableArray(a)&&(a=a.toArray());if(!1===f.isArray(a))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);if(1<d.length){if(!1===f.isFunctionParameter(d[1]))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);var l=a;const h= |
|
d[1].createFunction(b);return c?t(l,h):l=p(l,(m,u)=>h(m,u))}b=a;if(0===b.length)return[];d={};for(c=0;c<b.length;c++)e=f.getType(b[c]),""!==e&&(d[e]=!0);if(!0===d.Array||!0===d.Dictionary||!0===d.Feature||!0===d.Point||!0===d.Polygon||!0===d.Polyline||!0===d.Multipoint||!0===d.Extent||!0===d.Function)return b.slice(0);c=0;e="";for(l in d)c++,e=l;return b=1<c||"String"===e?p(b,(h,m)=>{if(null===h||void 0===h||h===f.voidOperation)return null===m||void 0===m||m===f.voidOperation?0:1;if(null===m||void 0=== |
|
m||m===f.voidOperation)return-1;h=f.toString(h);m=f.toString(m);return h<m?-1:h===m?0:1}):"Number"===e?p(b,(h,m)=>h-m):"Boolean"===e?p(b,(h,m)=>h===m?0:m?-1:1):"Date"===e?p(b,(h,m)=>m-h):b.slice(0)}k.functions.array=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,0,2,b,e);if(0===a.length||1===a.length&&null===a[0])return[];if(f.isArray(a[0])){if(2===a.length&&!1===f.isBoolean(a[1]))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);return!0===f.defaultUndefined(a[1], |
|
!1)?w.deepClone(a[0]):a[0].slice(0)}if(f.isImmutableArray(a[0])){if(2===a.length&&!1===f.isBoolean(a[1]))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);return!0===f.defaultUndefined(a[1],!1)?w.deepClone(a[0]):a[0].toArray().slice(0)}d=f.toNumber(a[0]);if(isNaN(d)||!1===f.isInteger(d))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);a=f.defaultUndefined(a[1],null);d=Array(d);d.fill(a);return d})};k.functions.front=function(b,e){return k.standardFunction(b, |
|
e,(d,c,a)=>{f.pcCheck(a,1,1,b,e);if(f.isImmutableArray(a[0])){if(0>=a[0].length())throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);return a[0].get(0)}if(f.isArray(a[0])){if(0>=a[0].length)throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);return a[0][0]}throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);})};k.functions.back=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,1,1,b,e);if(f.isImmutableArray(a[0])){if(0>= |
|
a[0].length())throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);return a[0].get(a[0].length()-1)}if(f.isArray(a[0])){if(0>=a[0].length)throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);return a[0][a[0].length-1]}throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);})};k.functions.push=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,1,2,b,e);if(f.isArray(a[0]))return a[0][a[0].length]=a[1],a[0].length;throw new g.ArcadeExecutionError(b, |
|
g.ExecutionErrorCodes.InvalidParameter,e);})};k.functions.pop=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,1,1,b,e);if(f.isArray(a[0])){if(0>=a[0].length)throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);d=a[0][a[0].length-1];--a[0].length;return d}throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);})};k.functions.erase=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,2,2,b,e);if(f.isArray(a[0])){d=f.toNumber(a[1]); |
|
if(isNaN(d)||!1===f.isInteger(d))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);a=a[0];if(0>=a.length)throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);0>d&&(d=a.length+d);if(0>d)throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);if(d>=a.length)throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);a.splice(d,1);return f.voidOperation}throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter, |
|
e);})};k.functions.insert=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,3,3,b,e);if(f.isArray(a[0])){d=f.toNumber(a[1]);if(isNaN(d)||!1===f.isInteger(d))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);c=a[2];a=a[0];if(d>a.length)throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);if(0>d&&d<-1*a.length)throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.OutOfBounds,e);if(d===a.length)return a[d]=c,f.voidOperation;a.splice(d, |
|
0,c);return f.voidOperation}throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);})};k.functions.resize=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,2,3,b,e);if(f.isArray(a[0])){c=f.toNumber(a[1]);if(isNaN(c)||!1===f.isInteger(c))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);if(0>c)throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);d=f.defaultUndefined(a[2],null);a=a[0];if(a.length>=c)return a.length= |
|
c,f.voidOperation;const l=a.length;a.length=c;for(c=l;c<a.length;c++)a[c]=d;return f.voidOperation}throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);})};k.functions.includes=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,2,2,b,e);if(f.isArray(a[0])){const l=a[1];return-1<a[0].findIndex(h=>f.equalityTest(h,l))?!0:!1}if(f.isImmutableArray(a[0])){const l=a[1];return-1<a[0].toArray().findIndex(h=>f.equalityTest(h,l))?!0:!1}throw new g.ArcadeExecutionError(b, |
|
g.ExecutionErrorCodes.InvalidParameter,e);})};k.functions.slice=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,1,3,b,e);if(f.isArray(a[0])){d=f.toNumber(f.defaultUndefined(a[1],0));c=f.toNumber(f.defaultUndefined(a[2],a[0].length));if(isNaN(d)||!1===f.isInteger(d))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);if(isNaN(c)||!1===f.isInteger(c))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);return a[0].slice(d,c)}if(f.isImmutableArray(a[0])){d= |
|
a[0];c=f.toNumber(f.defaultUndefined(a[1],0));a=f.toNumber(f.defaultUndefined(a[2],d.length()));if(isNaN(c)||!1===f.isInteger(c))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);if(isNaN(a)||!1===f.isInteger(a))throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);return d.toArray().slice(c,a)}throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter,e);})};k.functions.splice=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{d= |
|
[];for(c=0;c<a.length;c++)f.isArray(a[c])?d.push(...a[c]):f.isImmutableArray(a[c])?d.push(...a[c].toArray()):d.push(a[c]);return d})};k.functions.top=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,2,2,b,e);if(f.isArray(a[0]))return f.toNumber(a[1])>=a[0].length?a[0].slice(0):a[0].slice(0,f.toNumber(a[1]));if(f.isImmutableArray(a[0]))return f.toNumber(a[1])>=a[0].length()?a[0].slice(0):a[0].slice(0,f.toNumber(a[1]));throw new g.ArcadeExecutionError(b,g.ExecutionErrorCodes.InvalidParameter, |
|
e);})};k.functions.first=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,1,1,b,e);return f.isArray(a[0])?0===a[0].length?null:a[0][0]:f.isImmutableArray(a[0])?0===a[0].length()?null:a[0].get(0):null})};"sync"===k.mode&&(k.functions.sort=function(b,e){return k.standardFunction(b,e,(d,c,a)=>y(b,c,a,!1))},k.functions.any=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);c=n(a[0],b,c);for(const l of c)if(c=d(l),f.isBoolean(c)&&!0===c)return!0; |
|
return!1})},k.functions.all=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);c=n(a[0],b,c);for(const l of c)if(!0!==d(l))return!1;return!0})},k.functions.none=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);c=n(a[0],b,c);for(const l of c)if(!0===d(l))return!1;return!0})},k.functions.reduce=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,2,3,b,c);const l=a[1].createFunction(b);d= |
|
n(a[0],b,c);return 2===a.length?0===d.length?null:d.reduce((h,m)=>{h=l(h,m);return h=void 0!==h&&h!==f.voidOperation?h:null}):d.reduce((h,m)=>{h=l(h,m);return h=void 0!==h&&h!==f.voidOperation?h:null},a[2])})},k.functions.map=function(b,e){return k.standardFunction(b,e,(d,c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);a=n(a[0],b,c);c=[];for(const l of a)a=d(l),void 0!==a&&a!==f.voidOperation?c.push(a):c.push(null);return c})},k.functions.filter=function(b,e){return k.standardFunction(b,e,(d, |
|
c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);c=n(a[0],b,c);a=[];for(const l of c)!0===d(l)&&a.push(l);return a})});"async"===k.mode&&(k.functions.sort=function(b,e){return k.standardFunctionAsync(b,e,async(d,c,a)=>y(b,c,a,!0))},k.functions.any=function(b,e){return k.standardFunctionAsync(b,e,async(d,c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);c=n(a[0],b,c);for(const l of c)if(c=await d(l),a=null,a=q.isPromiseLike(a)?await c:c,f.isBoolean(a)&&!0===a)return!0;return!1})},k.functions.all= |
|
function(b,e){return k.standardFunctionAsync(b,e,async(d,c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);c=n(a[0],b,c);for(const l of c)if(c=await d(l),a=null,a=q.isPromiseLike(a)?await c:c,!0!==a)return!1;return!0})},k.functions.none=function(b,e){return k.standardFunctionAsync(b,e,async(d,c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);c=n(a[0],b,c);for(const l of c)if(c=await d(l),a=null,a=q.isPromiseLike(a)?await c:c,!0===a)return!1;return!0})},k.functions.filter=function(b,e){return k.standardFunctionAsync(b, |
|
e,async(d,c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);a=n(a[0],b,c);c=[];for(const l of a){a=await d(l);let h=null;h=q.isPromiseLike(h)?await a:a;!0===h&&c.push(l)}return c})},k.functions.reduce=function(b,e){return k.standardFunctionAsync(b,e,async(d,c,a)=>{f.pcCheck(a,2,3,b,c);const l=a[1].createFunction(b);d=n(a[0],b,c);if(2<a.length)a=f.defaultUndefined(a[2],null),a=d.reduce(async(h,m)=>{h=await h;if(void 0===h||h===f.voidOperation)h=null;return l(h,m)},Promise.resolve(a));else{if(0=== |
|
d.length)return null;a=d.reduce(async(h,m,u)=>{if(1>=u)return l(h,m);h=await h;if(void 0===h||h===f.voidOperation)h=null;return l(h,m)})}return a.then(h=>void 0!==h&&h!==f.voidOperation?h:null)})},k.functions.map=function(b,e){return k.standardFunctionAsync(b,e,async(d,c,a)=>{f.pcCheck(a,2,2,b,c);d=a[1].createFunction(b);a=n(a[0],b,c);c=[];for(const l of a){a=await d(l);let h=null;h=q.isPromiseLike(h)?await a:a;void 0!==h&&h!==f.voidOperation?c.push(h):c.push(null)}return c})})}const A=Object.freeze(Object.defineProperty({__proto__:null, |
|
registerFunctions:x},Symbol.toStringTag,{value:"Module"}));v.ArrayFunctions=A;v.registerFunctions=x}); |