diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 673bd33..bed96a2 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [10.x, 12.x, 14.x] + node-version: [12.x, 14.x] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 065a6c8..467d48f 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,6 @@ const lookup = async () => { const numUri = parseNumUri('num.uk:1'); // Parse the NUM URI const client = createClient(); // Create a NumClient const ctx = client.createContext(numUri); // Set the lookup context - ctx.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) const result = await client.retrieveNumRecord(ctx); // Use the context to retrieve a NUM record console.log(result); // Handle the result } @@ -83,8 +82,6 @@ const lookup = async () => { const ctx1 = client.createContext(numUri1); const ctx2 = client.createContext(numUri2); - ctx1.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) - ctx2.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) const result1 = client.retrieveNumRecord(ctx1); const result2 = client.retrieveNumRecord(ctx2); @@ -109,22 +106,6 @@ const lookup = async () => { // ... }; ``` -## Providing User Variable Values -Some modules can be provided with User Variable values to customise the output, as in this example: -```typescript -const lookup = async () => { - const numUri = parseNumUri('num.uk:1'); // Parse the NUM URI - const client = createClient(); // Create a NumClient - const ctx = client.createContext(numUri); // Set the lookup context - ctx.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) - - ctx.setUserVariable('_L', 'en'); // Set the user's language - ctx.setUserVariable('_C', 'gb'); // Set the user's country - - const result = await client.retrieveNumRecord(ctx); // Use the context to retrieve a NUM record - console.log(result) // Handle the result -} -``` ## Using a `CallbackHandler` Lookups _can_ take several seconds, so you can provide a `CallbackHandler` rather than `await`ing the results: ```Typescript @@ -132,7 +113,6 @@ const lookup = async () => { const numUri = parseNumUri('num.uk:1'); // Parse the NUM URI const client = createClient(); // Create a NumClient const ctx = client.createContext(numUri); // Set the lookup context - ctx.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) const handler: CallbackHandler = { setLocation: (l: NumLocation): void => { @@ -163,8 +143,7 @@ num.lookup('num.uk:1').then((result) => console.log(result)); This example shows how to use all features of the client, including - overriding the DoH resolver, - reusing the `NUMClient` -- setting user variables -- using a callback handler +- using a callback handler ```javascript const num = require('num-client'); @@ -181,14 +160,6 @@ function lookup(uri1, uri2) { const ctx1 = client.createContext(numUri1); const ctx2 = client.createContext(numUri2); - ctx1.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) - ctx2.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) - - ctx1.setUserVariable('_L', 'en'); // Set the user's language - ctx1.setUserVariable('_C', 'gb'); // Set the user's country - - ctx2.setUserVariable('_L', 'en'); // Set the user's language - ctx2.setUserVariable('_C', 'us'); // Set the user's country const handler = { // Provide a custom CallbackHandler setLocation: (l) => { @@ -218,57 +189,82 @@ This simple example can be modified as necessary by following the previous examp ```html - -
- -