@fileverse-dev/formulajs 4.4.42-yield-a → 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
@@ -19492,26 +19492,39 @@ const yieldParamsSchema = objectType({
19492
19492
  columnName: stringType().optional(),
19493
19493
  });
19494
19494
 
19495
- async function YIELD () {
19495
+ async function YIELD() {
19496
19496
 
19497
19497
  try {
19498
- const [category, columnName] = argsToArray(arguments);
19499
-
19500
- validateParams(yieldParamsSchema, { category, columnName });
19501
-
19502
- const response = await DEFILLAMA('yields', columnName);
19503
-
19504
- if(response.functionName){
19505
- response.functionName = 'YIELD';
19506
- return response
19507
- }
19508
-
19509
- if(category === 'all'){
19510
- 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;
19511
19524
  }
19512
- const result = response.filter(data => data.stablecoin);
19513
- return result
19514
-
19525
+ return out
19526
+ })
19527
+
19515
19528
  } catch (error) {
19516
19529
  return errorMessageHandler(error, 'YIELD')
19517
19530
  }
package/lib/esm/index.mjs CHANGED
@@ -19490,26 +19490,39 @@ const yieldParamsSchema = objectType({
19490
19490
  columnName: stringType().optional(),
19491
19491
  });
19492
19492
 
19493
- async function YIELD () {
19493
+ async function YIELD() {
19494
19494
 
19495
19495
  try {
19496
- const [category, columnName] = argsToArray(arguments);
19497
-
19498
- validateParams(yieldParamsSchema, { category, columnName });
19499
-
19500
- const response = await DEFILLAMA('yields', columnName);
19501
-
19502
- if(response.functionName){
19503
- response.functionName = 'YIELD';
19504
- return response
19505
- }
19506
-
19507
- if(category === 'all'){
19508
- 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;
19509
19522
  }
19510
- const result = response.filter(data => data.stablecoin);
19511
- return result
19512
-
19523
+ return out
19524
+ })
19525
+
19513
19526
  } catch (error) {
19514
19527
  return errorMessageHandler(error, 'YIELD')
19515
19528
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/formulajs",
3
- "version": "4.4.42-yield-a",
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": {
@@ -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.
@@ -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.