(
newValue: string | number | boolean | Series | ArrayType1D,
index: Array<number | string> | number | string,
options?: { inplace?: boolean }
)
| 1853 | options?: { inplace?: boolean } |
| 1854 | ): Series |
| 1855 | append( |
| 1856 | newValue: string | number | boolean | Series | ArrayType1D, |
| 1857 | index: Array<number | string> | number | string, |
| 1858 | options?: { inplace?: boolean } |
| 1859 | ): Series | void { |
| 1860 | const { inplace } = { inplace: false, ...options } |
| 1861 | |
| 1862 | if (!newValue && typeof newValue !== "boolean" && typeof newValue !== "number") { |
| 1863 | throw Error("Param Error: newValue cannot be null or undefined"); |
| 1864 | } |
| 1865 | |
| 1866 | if (!index) { |
| 1867 | throw Error("Param Error: index cannot be null or undefined"); |
| 1868 | } |
| 1869 | |
| 1870 | const newData = [...this.values] |
| 1871 | const newIndx = [...this.index] |
| 1872 | |
| 1873 | if (Array.isArray(newValue) && Array.isArray(index)) { |
| 1874 | |
| 1875 | if (newValue.length !== index.length) { |
| 1876 | throw Error("Param Error: Length of new values and index must be the same"); |
| 1877 | } |
| 1878 | |
| 1879 | newValue.forEach((el, i) => { |
| 1880 | newData.push(el); |
| 1881 | newIndx.push(index[i]); |
| 1882 | }); |
| 1883 | |
| 1884 | } else if (newValue instanceof Series) { |
| 1885 | const _value = newValue.values; |
| 1886 | |
| 1887 | if (!Array.isArray(index)) { |
| 1888 | throw Error("Param Error: index must be an array"); |
| 1889 | } |
| 1890 | |
| 1891 | if (index.length !== _value.length) { |
| 1892 | throw Error("Param Error: Length of new values and index must be the same"); |
| 1893 | } |
| 1894 | |
| 1895 | _value.forEach((el, i) => { |
| 1896 | newData.push(el); |
| 1897 | newIndx.push(index[i]); |
| 1898 | }); |
| 1899 | } else { |
| 1900 | newData.push(newValue); |
| 1901 | newIndx.push(index as string | number); |
| 1902 | } |
| 1903 | |
| 1904 | if (inplace) { |
| 1905 | this.$setValues(newData as ArrayType1D, false) |
| 1906 | this.$setIndex(newIndx) |
| 1907 | } else { |
| 1908 | const sf = new Series( |
| 1909 | newData, |
| 1910 | { |
| 1911 | index: newIndx, |
| 1912 | columns: this.columns, |
nothing calls this directly
no test coverage detected