UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

1 lines 1.36 kB
Object.defineProperty(exports,"__esModule",{value:!0});let APIFunction_1=require("../../classes/structures/APIFunction");function binaryXor(t,n){var e=t.filter(e=>!n.includes(e)),r=n.filter(e=>!t.includes(e));return Array.from(new Set([...e,...r]))}function xor(...e){return e.reduce(binaryXor,[])}class XOR extends APIFunction_1.APIFunction{name="$xor";description="Creates an string of unique values that is the symmetric difference of the given elements. The order of result values is determined by the order they occur in the given elements.";parameters=[{name:"Separator",description:"Elements and result separator.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Lefthand Elements",description:"Lefthand elements to apply the XOR function.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Righthand Elements",description:"Righthand elements to apply the XOR function.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null}];usage="$xor[separator;lefthandElements;righthandElements]";example=['$toBe[Might return "1,4,3,6";1,4,3,6;$xor[,;2,1,4;2,3,2,6]]','$toBe[Might return "1,3";1,3;$xor[,;1,1,2;2,2,3]]'].join("\n");returns=APIFunction_1.ParamType.String;aliases=[];compile=!0;async run(e,[t,n,r]){return xor(n.split(t),r.split(t)).join(t)}}exports.default=XOR;