same.js
Version:
A Class of Parallel Arrays Manipulation
101 lines (87 loc) • 5.11 kB
TypeScript
declare module 'Same' {
export class Same {
/**
* The Same in its insides
*/
constructor();
/**
* Inserts in the Same two values
* @param {any} [firstValue] The value stored in the first array of the Same
* @param {any} [secondValue] The value stored in the second array of the Same
* @returns {number} The new Same length
*/
public insert(firstValue: any, secondValue: any): number;
/**
* Overwrites the value into the corresponding one; if there are more indexes with the same value, it returns an array of its overwritten values
* @param {any} [value] The value in the same index of its correspoding
* @returns {any} The corresponding value of the first parameter
*/
public over(value: any): any;
/**
* Loops thorught every element in the Same and checks if there's the value to search for
* @param {any} [value] The value to check
* @returns {boolean | object[]} If the value is not in the same returns false, else returns more objects containing infos about the position of the value found
*/
public has(value: any): boolean | object[];
/**
* Replaces every undefined variable inside the Same (FROM THE FIRST ARRAY TO THE SECOND)
* @param {any[]} [elements] The array of elements to replace in order
* @returns {number} The new Same length
*/
public replaceUnd(elements: any[]): number;
/**
* Replaces the variables in the Same from the index
* @param {number | any} [index] The index of the variables to replace (it can be one of the values itself)
* @param {boolean} [isIndex] Checks if the number inserted as [index] is an index or a variable inside the Same
* @param {any} [firstElement] The value to replace in the first array
* @param {any} [secondElement] The value to replace in the second array
* @returns {any[]} An array of the replaced elements
*/
public replace(index: number | any, isIndex: boolean, firstElement: any, secondElement: any): any[];
/**
* Only returns an Object with an array of a part from the first and second arrays (DOES NOT DELETE THE ELEMENTS FROM THE SAME)
* @param {number | any} firstIndex The index of the Same from where the selection starts (it may be the value of the index itself)
* @param {number | any} lastIndex The index of the Same form where the selection ends (it may be the value of the index itself)
* @returns {object} The container of the elements cut in the first and second array
*/
public cut(firstIndex: number | any, lastIndex: number | any): { firstElement: any[], secondElement: any[] };
/**
* Removes one or more elements at the indexes
* @param {number | any | any[]} [value] The index from where the selection starts; it can be the value of the index itself; if it's an array of values, 'spaces' can be omitted
* @param {boolean} [isIndex] Decides if the value must be an index of the array or the value of an element (default: true -- has no effect if value is not a number or an array of numbers)
* @param {number} [spaces] The number of indexes that will be removed after the first one (default: 1)
* @returns {number} The new Same length
*/
public remove(value: number | any | any[], isIndex: boolean, spaces: number): number;
/**
* Reads how long is the first array of the Same
* @returns {number} The Same length
*/
public length(): number;
/**
* Executes a code for every elements inside the first array of the Same first, and then in the second one
* @param {Function} [callback] The code that will be executed with every elements in the Same as parameter
* @returns {Promise<any>} Nothing.
*/
public forEach(callback: Function): Promise<any>;
/**
* Translates every number between the parameters (included) from decimal to spoken language and inserts the numbers in the first array, and the translations in the second one
* @param {number} [from] The number from where the translation will start
* @param {number} [to] The number from where the translation will end
* @returns {number} The new Same length
*/
public charNumbInsert(from: number, to: number): Promise<number>;
/**
* Generates and thorws an error where the value to overwrite was not in the Same
*/
public NoValue(): void;
/**
* Generates and throws an error where the argument was not a Function to execute
*/
public NoFn(): void;
/**
* Generates and throws an error where the argument was not a Number
*/
public _0Value(): void;
}
}