@fileverse-dev/formulajs 4.4.42-yield → 4.4.42-yield-b

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/lib/cjs/index.cjs CHANGED
@@ -18011,7 +18011,7 @@ function toTimestamp(dateStr) {
18011
18011
 
18012
18012
  async function EOA() {
18013
18013
  try {
18014
- const [addresses, category, chains, startTime, endTime, page = 1, offset = 10, columnName = null] =
18014
+ const [addresses, category, chains, startTime, endTime, page = 1, offset = 10, columnName] =
18015
18015
  argsToArray(arguments);
18016
18016
  validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset, columnName });
18017
18017
 
@@ -18352,7 +18352,7 @@ const coingeckoParamsSchema = discriminatedUnionType('category', [
18352
18352
 
18353
18353
  async function COINGECKO() {
18354
18354
  try {
18355
- const [category, param1, param2, columnName = null] = argsToArray(arguments);
18355
+ const [category, param1, param2, columnName] = argsToArray(arguments);
18356
18356
  validateParams(coingeckoParamsSchema, { category, param1, param2, columnName });
18357
18357
 
18358
18358
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Coingecko);
@@ -18446,7 +18446,7 @@ const CATEGORY_URLS = {
18446
18446
 
18447
18447
  async function DEFILLAMA() {
18448
18448
  try {
18449
- const [category, columnName = null] = argsToArray(arguments);
18449
+ const [category, columnName] = argsToArray(arguments);
18450
18450
  validateParams(defillamaParamsSchema, { category, columnName });
18451
18451
  const url = CATEGORY_URLS[category];
18452
18452
  if (!url) throw new ValidationError(`Invalid category: ${category}`)
@@ -18470,6 +18470,7 @@ async function DEFILLAMA() {
18470
18470
  const filterColumnName = columnName?.split(',').map(s => s.trim());
18471
18471
 
18472
18472
  return (Array.isArray(json) ? json : [json]).map(item => {
18473
+ if (!filterColumnName) return item
18473
18474
  const out = {};
18474
18475
  for (const [k, v] of Object.entries(item)) {
18475
18476
  if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) out[k] = v;
@@ -18512,7 +18513,7 @@ const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSche
18512
18513
 
18513
18514
  async function ETHERSCAN() {
18514
18515
  try {
18515
- const [type, chain, address, startDate, endDate, page = 1, limit = 10, columnName = null] =
18516
+ const [type, chain, address, startDate, endDate, page = 1, limit = 10, columnName] =
18516
18517
  argsToArray(arguments);
18517
18518
 
18518
18519
 
@@ -19491,26 +19492,39 @@ const yieldParamsSchema = objectType({
19491
19492
  columnName: stringType().optional(),
19492
19493
  });
19493
19494
 
19494
- async function YIELD () {
19495
+ async function YIELD() {
19495
19496
 
19496
19497
  try {
19497
- const [category, columnName = null] = argsToArray(arguments);
19498
-
19499
- validateParams(yieldParamsSchema, { category, columnName });
19500
-
19501
- const response = await DEFILLAMA('yields', columnName);
19502
-
19503
- if(response.functionName){
19504
- response.functionName = 'YIELD';
19505
- return response
19506
- }
19507
-
19508
- if(category === 'all'){
19509
- return response
19498
+ const [category, columnName] = argsToArray(arguments);
19499
+
19500
+ validateParams(yieldParamsSchema, { category, columnName });
19501
+
19502
+ const response = await DEFILLAMA('yields');
19503
+ let returnValue;
19504
+
19505
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
19506
+
19507
+ if (response.functionName) {
19508
+ response.functionName = 'YIELD';
19509
+ returnValue = response;
19510
+ }
19511
+
19512
+ if (category === 'all') {
19513
+ returnValue = response;
19514
+ }
19515
+
19516
+ const result = response.filter(data => data.stablecoin);
19517
+ returnValue = result;
19518
+
19519
+ return (Array.isArray(returnValue) ? returnValue : [returnValue]).map(item => {
19520
+ if (!filterColumnName) return item
19521
+ const out = {};
19522
+ for (const [k, v] of Object.entries(item)) {
19523
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) out[k] = v;
19510
19524
  }
19511
- const result = response.filter(data => data.stablecoin);
19512
- return result
19513
-
19525
+ return out
19526
+ })
19527
+
19514
19528
  } catch (error) {
19515
19529
  return errorMessageHandler(error, 'YIELD')
19516
19530
  }
@@ -1264,6 +1264,13 @@ var YIELD_metadata = {
1264
1264
  example: `"stablecoins"`,
1265
1265
  require: "m",
1266
1266
  type: "string"
1267
+ },
1268
+ {
1269
+ name: "columnsName",
1270
+ detail: "Filter columns by name in output. Comma separated list.",
1271
+ example: `"id,address"`,
1272
+ require: "o",
1273
+ type: "string"
1267
1274
  }
1268
1275
  ],
1269
1276
  examples: [{
package/lib/esm/index.mjs CHANGED
@@ -18009,7 +18009,7 @@ function toTimestamp(dateStr) {
18009
18009
 
18010
18010
  async function EOA() {
18011
18011
  try {
18012
- const [addresses, category, chains, startTime, endTime, page = 1, offset = 10, columnName = null] =
18012
+ const [addresses, category, chains, startTime, endTime, page = 1, offset = 10, columnName] =
18013
18013
  argsToArray(arguments);
18014
18014
  validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset, columnName });
18015
18015
 
@@ -18350,7 +18350,7 @@ const coingeckoParamsSchema = discriminatedUnionType('category', [
18350
18350
 
18351
18351
  async function COINGECKO() {
18352
18352
  try {
18353
- const [category, param1, param2, columnName = null] = argsToArray(arguments);
18353
+ const [category, param1, param2, columnName] = argsToArray(arguments);
18354
18354
  validateParams(coingeckoParamsSchema, { category, param1, param2, columnName });
18355
18355
 
18356
18356
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Coingecko);
@@ -18444,7 +18444,7 @@ const CATEGORY_URLS = {
18444
18444
 
18445
18445
  async function DEFILLAMA() {
18446
18446
  try {
18447
- const [category, columnName = null] = argsToArray(arguments);
18447
+ const [category, columnName] = argsToArray(arguments);
18448
18448
  validateParams(defillamaParamsSchema, { category, columnName });
18449
18449
  const url = CATEGORY_URLS[category];
18450
18450
  if (!url) throw new ValidationError(`Invalid category: ${category}`)
@@ -18468,6 +18468,7 @@ async function DEFILLAMA() {
18468
18468
  const filterColumnName = columnName?.split(',').map(s => s.trim());
18469
18469
 
18470
18470
  return (Array.isArray(json) ? json : [json]).map(item => {
18471
+ if (!filterColumnName) return item
18471
18472
  const out = {};
18472
18473
  for (const [k, v] of Object.entries(item)) {
18473
18474
  if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) out[k] = v;
@@ -18510,7 +18511,7 @@ const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSche
18510
18511
 
18511
18512
  async function ETHERSCAN() {
18512
18513
  try {
18513
- const [type, chain, address, startDate, endDate, page = 1, limit = 10, columnName = null] =
18514
+ const [type, chain, address, startDate, endDate, page = 1, limit = 10, columnName] =
18514
18515
  argsToArray(arguments);
18515
18516
 
18516
18517
 
@@ -19489,26 +19490,39 @@ const yieldParamsSchema = objectType({
19489
19490
  columnName: stringType().optional(),
19490
19491
  });
19491
19492
 
19492
- async function YIELD () {
19493
+ async function YIELD() {
19493
19494
 
19494
19495
  try {
19495
- const [category, columnName = null] = argsToArray(arguments);
19496
-
19497
- validateParams(yieldParamsSchema, { category, columnName });
19498
-
19499
- const response = await DEFILLAMA('yields', columnName);
19500
-
19501
- if(response.functionName){
19502
- response.functionName = 'YIELD';
19503
- return response
19504
- }
19505
-
19506
- if(category === 'all'){
19507
- return response
19496
+ const [category, columnName] = argsToArray(arguments);
19497
+
19498
+ validateParams(yieldParamsSchema, { category, columnName });
19499
+
19500
+ const response = await DEFILLAMA('yields');
19501
+ let returnValue;
19502
+
19503
+ const filterColumnName = columnName?.split(',').map(s => s.trim());
19504
+
19505
+ if (response.functionName) {
19506
+ response.functionName = 'YIELD';
19507
+ returnValue = response;
19508
+ }
19509
+
19510
+ if (category === 'all') {
19511
+ returnValue = response;
19512
+ }
19513
+
19514
+ const result = response.filter(data => data.stablecoin);
19515
+ returnValue = result;
19516
+
19517
+ return (Array.isArray(returnValue) ? returnValue : [returnValue]).map(item => {
19518
+ if (!filterColumnName) return item
19519
+ const out = {};
19520
+ for (const [k, v] of Object.entries(item)) {
19521
+ if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) out[k] = v;
19508
19522
  }
19509
- const result = response.filter(data => data.stablecoin);
19510
- return result
19511
-
19523
+ return out
19524
+ })
19525
+
19512
19526
  } catch (error) {
19513
19527
  return errorMessageHandler(error, 'YIELD')
19514
19528
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/formulajs",
3
- "version": "4.4.42-yield",
3
+ "version": "4.4.42-yield-b",
4
4
  "description": "JavaScript implementation of most Microsoft Excel formula functions",
5
5
  "author": "Formulajs",
6
6
  "publishConfig": {
@@ -1187,7 +1187,7 @@ declare function DEC2OCT(number: any, places: any): any;
1187
1187
  * @returns
1188
1188
  */
1189
1189
  declare function DECIMAL(text: any, radix: any, ...args: any[]): any;
1190
- declare function DEFILLAMA(...args: any[]): Promise<{
1190
+ declare function DEFILLAMA(...args: any[]): Promise<any[] | {
1191
1191
  message: string;
1192
1192
  functionName: any;
1193
1193
  type: string;
@@ -1205,7 +1205,7 @@ declare function DEFILLAMA(...args: any[]): Promise<{
1205
1205
  type: string;
1206
1206
  reason: any;
1207
1207
  apiKeyName?: undefined;
1208
- } | {}[]>;
1208
+ }>;
1209
1209
  /**
1210
1210
  * Converts radians to degrees.
1211
1211
  *
@@ -4629,7 +4629,25 @@ declare function YEAR(serial_number: any): any;
4629
4629
  * @returns
4630
4630
  */
4631
4631
  declare function YEARFRAC(start_date: any, end_date: any, basis: any): number | Error;
4632
- declare function YIELD(...args: any[]): Promise<any>;
4632
+ declare function YIELD(...args: any[]): Promise<any[] | {
4633
+ message: string;
4634
+ functionName: any;
4635
+ type: string;
4636
+ apiKeyName?: undefined;
4637
+ reason?: undefined;
4638
+ } | {
4639
+ message: string;
4640
+ functionName: any;
4641
+ type: string;
4642
+ apiKeyName: any;
4643
+ reason?: undefined;
4644
+ } | {
4645
+ message: string;
4646
+ functionName: any;
4647
+ type: string;
4648
+ reason: any;
4649
+ apiKeyName?: undefined;
4650
+ }>;
4633
4651
  declare namespace Z {
4634
4652
  /**
4635
4653
  * Returns the one-tailed probability-value of a z-test.
@@ -1126,7 +1126,7 @@ export function DEC2OCT(number: any, places: any): any;
1126
1126
  * @returns
1127
1127
  */
1128
1128
  export function DECIMAL(text: any, radix: any, ...args: any[]): any;
1129
- export function DEFILLAMA(...args: any[]): Promise<{
1129
+ export function DEFILLAMA(...args: any[]): Promise<any[] | {
1130
1130
  message: string;
1131
1131
  functionName: any;
1132
1132
  type: string;
@@ -1144,7 +1144,7 @@ export function DEFILLAMA(...args: any[]): Promise<{
1144
1144
  type: string;
1145
1145
  reason: any;
1146
1146
  apiKeyName?: undefined;
1147
- } | {}[]>;
1147
+ }>;
1148
1148
  /**
1149
1149
  * Converts radians to degrees.
1150
1150
  *
@@ -4568,7 +4568,25 @@ export function YEAR(serial_number: any): any;
4568
4568
  * @returns
4569
4569
  */
4570
4570
  export function YEARFRAC(start_date: any, end_date: any, basis: any): number | Error;
4571
- export function YIELD(...args: any[]): Promise<any>;
4571
+ export function YIELD(...args: any[]): Promise<any[] | {
4572
+ message: string;
4573
+ functionName: any;
4574
+ type: string;
4575
+ apiKeyName?: undefined;
4576
+ reason?: undefined;
4577
+ } | {
4578
+ message: string;
4579
+ functionName: any;
4580
+ type: string;
4581
+ apiKeyName: any;
4582
+ reason?: undefined;
4583
+ } | {
4584
+ message: string;
4585
+ functionName: any;
4586
+ type: string;
4587
+ reason: any;
4588
+ apiKeyName?: undefined;
4589
+ }>;
4572
4590
  export namespace Z {
4573
4591
  /**
4574
4592
  * Returns the one-tailed probability-value of a z-test.