📘

As of version 1.2, jinqJs provides developers the ability to extend the jinqJs library very easily. jinqJs provides a function called addPlugin() to extend the library.

addPlugin

When calling the .addPlugin() both parameters are required. The first parameter is the name used to reference your plugin. The second parameter is the function to be called. There are three parameters that are passed to the function:

  • result: This is the working array that jinqJs uses when calling any of its built in functions. Remember this is a copy of the pointer to the array. Meaning you can make changes to the array, but you can’t create a new instance of an array.
  • args: This is an array of parameters that was passed when calling your plugin method.
  • store: Store provides a way for you to persist private data in between calls of your method.
addPlugin( pluginName, Function(result, args, store))
type PredicatePlugin = (result: any[], args: any[], store: any) => void;

addPlugin(pluginName: string, predicate: PredicatePlugin): void;

Example of adding your own custom jinqJs function to modify the results
This example is demonstrating adding your function as a chained function to jinqJs.

Example of creating a custom .select() that uses passed arguments and persistent storage. Call .selectCustom() multiple times to see the results.