### Install fast-deep-equal
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/fast-deep-equal/README.md
Install the library using npm.
```bash
npm install fast-deep-equal
```
--------------------------------
### Install json-schema-traverse
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/json-schema-traverse/README.md
Install the library using npm.
```bash
npm install json-schema-traverse
```
--------------------------------
### Install Punycode.js via npm
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/punycode/README.md
Install the library using npm for use in Node.js projects.
```bash
npm install punycode --save
```
--------------------------------
### Method Chaining Example
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Demonstrates method chaining for adding schemas and formats, and retrieving a schema.
```javascript
var validate = new Ajv().addSchema(schema).addFormat(name, regex).getSchema(uri);
```
--------------------------------
### Install AJV using npm
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Install the AJV library using npm. This is the first step to using AJV in your Node.js project.
```bash
npm install ajv
```
--------------------------------
### Install and Test AJV
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Commands to install dependencies, update git submodules, and run tests for the AJV project.
```bash
npm install
git submodule update --init
npm test
```
--------------------------------
### Install Ajv v7 Beta
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Install the beta version of Ajv v7 to access the latest features and changes.
```bash
npm install ajv@beta
```
--------------------------------
### Example Schema using $merge
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Demonstrates how to use the $merge keyword to extend a JSON schema. The 'source' schema is merged with the 'with' schema.
```json
{
"$merge": {
"source": {
"type": "object",
"properties": { "p": { "type": "string" } },
"additionalProperties": false
},
"with": {
"properties": { "q": { "type": "number" } }
}
}
}
```
--------------------------------
### CommonJS/Module Environment Installation
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Install URI.js using npm or yarn for use in CommonJS or module environments. Then, require the library in your code.
```bash
npm install uri-js
# OR
yarn add uri-js
```
```javascript
const URI = require("uri-js");
```
--------------------------------
### Example Schema using $patch
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Demonstrates how to use the $patch keyword to extend a JSON schema. The 'source' schema is patched with the operations defined in 'with'.
```json
{
"$patch": {
"source": {
"type": "object",
"properties": { "p": { "type": "string" } },
"additionalProperties": false
},
"with": [
{ "op": "add", "path": "/properties/q", "value": { "type": "number" } }
]
}
}
```
--------------------------------
### Using nodent with Ajv Async
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Example of integrating Ajv with the nodent transpiler for asynchronous validation functions. This is typically done by requiring the `ajv-async` package.
```javascript
var ajv = new Ajv;
require('ajv-async')(ajv);
// in the browser if you want to load ajv-async bundle separately you can:
// window.ajvAsync(ajv);
var validate = ajv.compile(schema); // transpiled es7 async function
validate(data).then(successFunc).catch(errorFunc);
```
--------------------------------
### Equivalent Schema after $merge or $patch
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
This schema is the result of applying either the $merge or $patch example schemas.
```json
{
"type": "object",
"properties": {
"p": { "type": "string" },
"q": { "type": "number" }
},
"additionalProperties": false
}
```
--------------------------------
### Validate using $data for Maximum Value
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
This example demonstrates how to use a $data reference to set the 'maximum' keyword. It ensures that the value of 'smaller' is less than or equal to the value of 'larger' in the validated data.
```javascript
var ajv = new Ajv({$data: true});
var schema = {
"properties": {
"smaller": {
"type": "number",
"maximum": { "$data": "1/larger" }
},
"larger": { "type": "number" }
}
};
var validData = {
smaller: 5,
larger: 7
};
ajv.validate(schema, validData); // true
```
--------------------------------
### Validate using $data for Format
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
This example shows how to use a $data reference to dynamically set the 'format' keyword based on property names. It validates that each property's value conforms to the format specified by its name (e.g., 'date-time', 'email').
```javascript
var schema = {
"additionalProperties": {
"type": "string",
"format": { "$data": "0#" }
}
};
var validData = {
'date-time': '1963-06-19T08:30:06.283185Z',
email: 'joe.bloggs@example.com'
}
```
--------------------------------
### Run Benchmark
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/fast-deep-equal/README.md
Execute the benchmark script to compare performance. Requires Node.js 6+.
```bash
npm run benchmark
```
--------------------------------
### Build AJV Templates
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Command to compile doT templates into JavaScript files for AJV.
```bash
npm run build
```
--------------------------------
### Basic Usage of fast-json-stable-stringify
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/fast-json-stable-stringify/README.md
Demonstrates the basic usage of the stringify function with a sample object. This ensures a consistent output order for JSON objects.
```javascript
var stringify = require('fast-json-stable-stringify');
var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
console.log(stringify(obj));
```
--------------------------------
### Decode UCS-2 string to code points
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/punycode/README.md
Use `punycode.ucs2.decode` to get an array of numeric code point values for each Unicode symbol in a string. Handles surrogate pairs correctly.
```javascript
punycode.ucs2.decode('abc');
// → [0x61, 0x62, 0x63]
// surrogate pair for U+1D306 TETRAGRAM FOR CENTRE:
punycode.ucs2.decode('\uD834\uDF06');
// → [0x1D306]
```
--------------------------------
### Importing fast-json-stable-stringify
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/fast-json-stable-stringify/README.md
Shows how to import the stringify function from the library. This is a prerequisite for using the library's functionality.
```javascript
var stringify = require('fast-json-stable-stringify')
```
--------------------------------
### Asynchronous Schema Compilation with Remote References
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Demonstrates how to compile a schema asynchronously when it includes remote references. Requires a `loadSchema` function to fetch external schemas.
```javascript
var ajv = new Ajv({ loadSchema: loadSchema });
ajv.compileAsync(schema).then(function (validate) {
var valid = validate(data);
// ...
});
function loadSchema(uri) {
return request.json(uri).then(function (res) {
if (res.statusCode >= 400)
throw new Error('Loading error: ' + res.statusCode);
return res.body;
});
}
```
--------------------------------
### Options
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Provides a comprehensive list of options that can be passed to URI.js functions for customization.
```APIDOC
## Options
All of the above functions can accept an additional options argument that is an object that can contain one or more of the following properties:
* `scheme` (string)
Indicates the scheme that the URI should be treated as, overriding the URI's normal scheme parsing behavior.
* `reference` (string)
If set to `"suffix"`, it indicates that the URI is in the suffix format, and the validator will use the option's `scheme` property to determine the URI's scheme.
* `tolerant` (boolean, false)
If set to `true`, the parser will relax URI resolving rules.
* `absolutePath` (boolean, false)
If set to `true`, the serializer will not resolve a relative `path` component.
* `iri` (boolean, false)
If set to `true`, the serializer will unescape non-ASCII characters as per [RFC 3987](http://www.ietf.org/rfc/rfc3987.txt).
* `unicodeSupport` (boolean, false)
If set to `true`, the parser will unescape non-ASCII characters in the parsed output as per [RFC 3987](http://www.ietf.org/rfc/rfc3987.txt).
* `domainHost` (boolean, false)
If set to `true`, the library will treat the `host` component as a domain name, and convert IDNs (International Domain Names) as per [RFC 5891](http://www.ietf.org/rfc/rfc5891.txt).
```
--------------------------------
### Compile Schemas Using addSchema Method
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Compile schemas with $ref by first adding the referenced schemas using `addSchema` and then compiling the main schema. This method is useful for incrementally building the schema collection.
```javascript
var ajv = new Ajv;
var validate = ajv.addSchema(defsSchema)
.compile(schema);
```
--------------------------------
### Compile Schemas by Passing All Schemas to Ajv
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Compile schemas that use $ref by initializing Ajv with an array of all relevant schemas. This allows Ajv to resolve references internally.
```javascript
var ajv = new Ajv({schemas: [schema, defsSchema]});
var validate = ajv.getSchema('http://example.com/schemas/schema.json');
```
--------------------------------
### Create Ajv Instance
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Instantiate the Ajv validator. Options can be passed to configure its behavior.
```javascript
var ajv = new Ajv();
```
--------------------------------
### Traversal with Pre and Post Callbacks
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/json-schema-traverse/README.md
Use pre and post callback functions for more granular control during schema traversal. 'pre' is called before traversing children, and 'post' is called after.
```javascript
const traverse = require('json-schema-traverse');
const schema = {
properties: {
foo: {type: 'string'},
bar: {type: 'integer'}
}
};
traverse(schema, {cb: {pre, post}});
// pre is called 3 times with:
// 1. root schema
// 2. {type: 'string'}
// 3. {type: 'integer'}
//
// post is called 3 times with:
// 1. {type: 'string'}
// 2. {type: 'integer'}
// 3. root schema
```
--------------------------------
### Require Punycode.js in Node.js
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/punycode/README.md
Import the library into your Node.js project using require.
```javascript
const punycode = require('punycode');
```
--------------------------------
### Serialize URI components
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Constructs a URI string from its components. Ensures correct formatting for serialization.
```javascript
URI.serialize({scheme : "http", host : "example.com", fragment : "footer"}) === "http://example.com/#footer"
```
--------------------------------
### Add Schema and Validate by Name with AJV
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Shows how to add a schema with a specific name using `ajv.addSchema` and then validate data against that named schema using `ajv.validate`. This is useful for managing multiple schemas.
```javascript
// ...
var valid = ajv.addSchema(schema, 'mySchema')
.validate('mySchema', data);
if (!valid) console.log(ajv.errorsText());
// ...
```
--------------------------------
### Basic Usage of fast-deep-equal
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/fast-deep-equal/README.md
Use the default export for basic deep equality checks on objects.
```javascript
var equal = require('fast-deep-equal');
console.log(equal({foo: 'bar'}, {foo: 'bar'})); // true
```
--------------------------------
### Ajv Constructor
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Creates a new instance of the Ajv validator with optional configuration options.
```APIDOC
## new Ajv(Object options)
### Description
Creates an Ajv instance with the specified options.
### Parameters
#### Options
- **options** (Object) - Configuration options for the Ajv instance.
```
--------------------------------
### Compare WS URIs
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Use URI.equal to compare WS URIs, ignoring case and port differences.
```javascript
URI.equal("WS://ABC.COM:80/chat#one", "ws://abc.com/chat") === true
```
--------------------------------
### ES6+/TypeScript Import
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Import the entire URI.js library using ES6+ or TypeScript syntax. Alternatively, import specific named exports for modularity.
```javascript
import * as URI from "uri-js";
```
```javascript
import { parse, serialize, resolve, resolveComponents, normalize, equal, removeDotSegments, pctEncChar, pctDecChars, escapeComponent, unescapeComponent } from "uri-js";
```
--------------------------------
### Watch for Template Changes
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Command to automatically recompile doT templates when changes are detected in the dot folder.
```bash
npm run watch
```
--------------------------------
### URI.equal
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Compares two URIs for equality.
```APIDOC
## URI.equal
### Description
Compares two URIs for equality, considering normalization and encoding differences.
### Method
`URI.equal(uri1, uri2)`
### Parameters
- **uri1** (string) - The first URI string.
- **uri2** (string) - The second URI string.
### Response
`true` if the URIs are equal, `false` otherwise.
### Request Example
```javascript
URI.equal("example://a/b/c/%7Bfoo%7D", "eXAMPLE://a/./b/../b/%63/%7Bfoo%7D")
```
### Response Example
```javascript
true
```
```
--------------------------------
### Add $merge and $patch Keywords to Ajv
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Instantiate Ajv and add the $merge and $patch keywords using the ajv-merge-patch package.
```javascript
require('ajv-merge-patch')(ajv);
```
--------------------------------
### Compare HTTP/HTTPS URIs
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Use URI.equal to compare HTTP and HTTPS URIs, ignoring case and port differences.
```javascript
URI.equal("HTTP://ABC.COM:80", "http://abc.com/") === true
URI.equal("https://abc.com", "HTTPS://ABC.COM:443/") === true
```
--------------------------------
### compileAsync
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Asynchronously compiles a JSON schema, loading any missing remote schemas. Returns a Promise that resolves to a validation function.
```APIDOC
## .compileAsync(Object schema [, Boolean meta] [, Function callback])
### Description
Asynchronously compiles a schema, loading missing remote schemas via `options.loadSchema`. Returns a Promise resolving to a validation function. An optional callback can be provided.
### Parameters
#### Schema
- **schema** (Object) - The JSON schema to compile.
#### Meta
- **meta** (Boolean) - Optional. If true, asynchronously compiles the meta-schema.
#### Callback
- **callback** (Function) - Optional. A callback function called with `(error, validatingFunction)`.
### Returns
- **Promise** - A Promise that resolves to the validating function. Rejects if schemas cannot be loaded or are invalid.
```
--------------------------------
### Include Ajv in Browser
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
To use Ajv in the browser, include the minified bundle via a script tag. This creates a global Ajv object if no module system is detected.
```html
```
--------------------------------
### punycode.version
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/punycode/README.md
A string representing the current Punycode.js version number.
```APIDOC
## punycode.version
### Description
A string representing the current Punycode.js version number.
### Request Example
```javascript
console.log(punycode.version);
// → '1.6.0' (example version)
```
```
--------------------------------
### Basic Schema Traversal
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/json-schema-traverse/README.md
Traverse a schema and pass each schema object to a callback function. The callback is called for the root schema and its nested properties.
```javascript
const traverse = require('json-schema-traverse');
const schema = {
properties: {
foo: {type: 'string'},
bar: {type: 'integer'}
}
};
traverse(schema, {cb});
// cb is called 3 times with:
// 1. root schema
// 2. {type: 'string'}
// 3. {type: 'integer'}
```
--------------------------------
### Usage with React
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/fast-deep-equal/README.md
Import specific versions for React integration to avoid issues with circular references in React elements.
```javascript
var equal = require('fast-deep-equal/react');
```
```javascript
var equal = require('fast-deep-equal/es6/react');
```
--------------------------------
### Compare two URIs for equality
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Compares two URIs for equality, considering normalization and percent-encoding. Returns true if they are equivalent, false otherwise.
```javascript
URI.equal("example://a/b/c/%7Bfoo%7D", "eXAMPLE://a/./b/../b/%63/%7Bfoo%7D") === true
```
--------------------------------
### Define Schemas with $ref
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Define schemas that reference definitions from other schema files using the $ref keyword. Ensure each schema has a unique $id for proper resolution.
```javascript
var schema = {
"$id": "http://example.com/schemas/schema.json",
"type": "object",
"properties": {
"foo": { "$ref": "defs.json#/definitions/int" },
"bar": { "$ref": "defs.json#/definitions/str" }
}
};
var defsSchema = {
"$id": "http://example.com/schemas/defs.json",
"definitions": {
"int": { "type": "integer" },
"str": { "type": "string" }
}
};
```
--------------------------------
### Using Other Transpilers with Ajv Async
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Shows how to configure Ajv to use a custom transpiler function for asynchronous validation code. The `processCode` option should be set to the transpiler function.
```javascript
var ajv = new Ajv({ processCode: transpileFunc });
var validate = ajv.compile(schema); // transpiled es7 async function
validate(data).then(successFunc).catch(errorFunc);
```
--------------------------------
### Compile Schema Asynchronously
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Compiles a JSON schema asynchronously, loading missing remote schemas. Returns a Promise that resolves to the validation function.
```javascript
var validate = await ajv.compileAsync(schema);
```
--------------------------------
### URI.parse
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Parses a URI string into its components.
```APIDOC
## URI.parse
### Description
Parses a URI string into its components.
### Method
`URI.parse(uri)`
### Parameters
- **uri** (string) - The URI string to parse.
### Response
An object containing the components of the URI (scheme, userinfo, host, port, path, query, fragment).
### Request Example
```javascript
URI.parse("uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body");
```
### Response Example
```json
{
"scheme": "uri",
"userinfo": "user:pass",
"host": "example.com",
"port": 123,
"path": "/one/two.three",
"query": "q1=a1&q2=a2",
"fragment": "body"
}
```
```
--------------------------------
### URI.normalize
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Normalizes a URI string.
```APIDOC
## URI.normalize
### Description
Normalizes a URI string according to RFC 3986 and other relevant specifications.
### Method
`URI.normalize(uri)`
### Parameters
- **uri** (string) - The URI string to normalize.
### Response
The normalized URI string.
### Request Example
```javascript
URI.normalize("HTTP://ABC.com:80/%7Esmith/home.html")
```
### Response Example
```javascript
"http://abc.com/~smith/home.html"
```
```
--------------------------------
### Asynchronous Validation with Custom Keywords
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Shows how to add and use an asynchronous custom keyword for validation. The keyword's validation function must return a promise.
```javascript
var ajv = new Ajv;
// require('ajv-async')(ajv);
ajv.addKeyword('idExists', {
async: true,
type: 'number',
validate: checkIdExists
});
function checkIdExists(schema, data) {
return knex(schema.table)
.select('id')
.where('id', data)
.then(function (rows) {
return !!rows.length; // true if record is found
});
}
var schema = {
"$async": true,
"properties": {
"userId": {
"type": "integer",
"idExists": { "table": "users" }
},
"postId": {
"type": "integer",
"idExists": { "table": "posts" }
}
}
};
var validate = ajv.compile(schema);
validate({ userId: 1, postId: 19 })
.then(function (data) {
console.log('Data is valid', data); // { userId: 1, postId: 19 }
})
.catch(function (err) {
if (!(err instanceof Ajv.ValidationError)) throw err;
// data is invalid
console.log('Validation errors:', err.errors);
});
```
--------------------------------
### Ajv Default Options Configuration
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
This object lists the default configuration options for Ajv. It covers settings for validation, reporting, schema referencing, data modification, strict modes, asynchronous validation, and advanced features. Adjust these options to customize Ajv's behavior.
```javascript
{
// validation and reporting options:
"$data": false,
"allErrors": false,
"verbose": false,
"$comment": false, // NEW in Ajv version 6.0
"jsonPointers": false,
"uniqueItems": true,
"unicode": true,
"nullable": false,
"format": 'fast',
"formats": {},
"unknownFormats": true,
"schemas": {},
"logger": undefined,
// referenced schema options:
"schemaId": '$id',
"missingRefs": true,
"extendRefs": 'ignore', // recommended 'fail'
"loadSchema": undefined, // function(uri: string): Promise {}
// options to modify validated data:
"removeAdditional": false,
"useDefaults": false,
"coerceTypes": false,
// strict mode options
"strictDefaults": false,
"strictKeywords": false,
"strictNumbers": false,
// asynchronous validation options:
"transpile": undefined, // requires ajv-async package
// advanced options:
"meta": true,
"validateSchema": true,
"addUsedSchema": true,
"inlineRefs": true,
"passContext": false,
"loopRequired": Infinity,
"ownProperties": false,
"multipleOfPrecision": false,
"errorDataPath": 'object', // deprecated
"messages": true,
"sourceCode": false,
"processCode": undefined, // function (str: string, schema: object): string {}
"cache": new Cache,
"serialize": undefined
}
```
--------------------------------
### Custom Key Sorting with fast-json-stable-stringify
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/fast-json-stable-stringify/README.md
Illustrates how to use a custom comparison function to sort object keys in reverse alphabetical order. This affects the order of properties in the output string.
```javascript
var stringify = require('fast-json-stable-stringify');
var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
var s = stringify(obj, function (a, b) {
return a.key < b.key ? 1 : -1;
});
console.log(s);
```
--------------------------------
### punycode.toUnicode(input)
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/punycode/README.md
Converts a Punycode string representing a domain name or an email address to Unicode. Only Punycode-encoded parts are converted.
```APIDOC
## punycode.toUnicode(input)
### Description
Converts a Punycode string representing a domain name or an email address to Unicode. Only the Punycoded parts of the input will be converted.
### Parameters
#### Path Parameters
- **input** (string) - Required - The Punycode string to convert to Unicode.
### Request Example
```javascript
// decode domain names
punycode.toUnicode('xn--maana-pta.com');
// → 'mañana.com'
punycode.toUnicode('xn----dqo34k.com');
// → '☃-⌘.com'
// decode email addresses
punycode.toUnicode('джумла@xn--p-8sbkgc5ag7bhce.xn--ba-lmcq');
// → 'джумла@джpумлатест.bрфa'
```
```
--------------------------------
### Traverse All Keys Including Unknown Keywords
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/json-schema-traverse/README.md
Enable traversal of objects within all keywords, including those not standard in JSON Schema, by setting the 'allKeys' option to true.
```javascript
const traverse = require('json-schema-traverse');
const schema = {
mySchema: {
minimum: 1,
maximum: 2
}
};
traverse(schema, {allKeys: true, cb});
// cb is called 2 times with:
// 1. root schema
// 2. mySchema
```
--------------------------------
### Browser Usage of URI.js
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Include this script tag in your HTML to load the URI.js library in a browser environment.
```html
```
--------------------------------
### Fastest Validation Call with AJV
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Demonstrates the fastest way to validate data using AJV by compiling a schema to a function and then using that function for validation. This method caches compiled schemas for performance.
```javascript
// Node.js require:
var Ajv = require('ajv');
// or ESM/TypeScript import
import Ajv from 'ajv';
var ajv = new Ajv(); // options can be passed, e.g. {allErrors: true}
var validate = ajv.compile(schema);
var valid = validate(data);
if (!valid) console.log(validate.errors);
```
--------------------------------
### Assigning Defaults to Object Properties
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Demonstrates how to use `useDefaults: true` to assign a default value to a missing property in an object. The original data object is modified in place.
```javascript
var ajv = new Ajv({ useDefaults: true });
var schema = {
"type": "object",
"properties": {
"foo": { "type": "number" },
"bar": { "type": "string", "default": "baz" }
},
"required": [ "foo", "bar" ]
};
var data = { "foo": 1 };
var validate = ajv.compile(schema);
console.log(validate(data)); // true
console.log(data); // { "foo": 1, "bar": "baz" }
```
--------------------------------
### URI.serialize
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Serializes a URI object back into a string.
```APIDOC
## URI.serialize
### Description
Serializes a URI object back into a string.
### Method
`URI.serialize(uriObject, [options])`
### Parameters
- **uriObject** (object) - The URI object to serialize.
- **options** (object, optional) - An object containing serialization options.
### Response
The serialized URI string.
### Request Example
```javascript
URI.serialize({scheme : "http", host : "example.com", fragment : "footer"})
```
### Response Example
```javascript
"http://example.com/#footer"
```
```
--------------------------------
### IRI Support
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Supports conversion between Internationalized Resource Identifiers (IRIs) and URIs.
```APIDOC
## IRI Support
### Description
Supports conversion between Internationalized Resource Identifiers (IRIs) and URIs, handling non-ASCII characters.
### Methods
- **URI.serialize(uriObject, {iri: true})**: Converts a parsed IRI object to a URI string (punycode).
- **URI.serialize(URI.parse(uri), {iri:true})**: Converts a URI string representing an IRI to its IRI representation.
### Examples
#### Convert IRI to URI
```javascript
URI.serialize(URI.parse("http://examplé.org/rosé"))
// returns: "http://xn--exampl-gva.org/ros%C3%A9"
```
#### Convert URI to IRI
```javascript
URI.serialize(URI.parse("http://xn--exampl-gva.org/ros%C3%A9"), {iri:true})
// returns: "http://examplé.org/rosé"
```
```
--------------------------------
### punycode.toASCII(input)
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/punycode/README.md
Converts a lowercased Unicode string representing a domain name or an email address to Punycode. Only non-ASCII parts are converted.
```APIDOC
## punycode.toASCII(input)
### Description
Converts a lowercased Unicode string representing a domain name or an email address to Punycode. Only the non-ASCII parts of the input will be converted.
### Parameters
#### Path Parameters
- **input** (string) - Required - The Unicode string to convert to Punycode.
### Request Example
```javascript
// encode domain names
punycode.toASCII('mañana.com');
// → 'xn--maana-pta.com'
punycode.toASCII('☃-⌘.com');
// → 'xn----dqo34k.com'
// encode email addresses
punycode.toASCII('джумла@джpумлатест.bрфa');
// → 'джумла@xn--p-8sbkgc5ag7bhce.xn--ba-lmcq'
```
```
--------------------------------
### Usage with ES6 Features
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/fast-deep-equal/README.md
Import the 'es6' version to support deep equality checks for Maps, Sets, and Typed arrays.
```javascript
var equal = require('fast-deep-equal/es6');
console.log(equal(Int16Array([1, 2]), Int16Array([1, 2]))); // true
```
--------------------------------
### Custom Logger Configuration in Ajv
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Configure Ajv to use a custom logger object with required methods: log, warn, and error. This allows integration with existing logging solutions.
```javascript
var otherLogger = new OtherLogger();
var ajv = new Ajv({
logger: {
log: console.log.bind(console),
warn: function warn() {
otherLogger.logWarn.apply(otherLogger, arguments);
},
error: function error() {
otherLogger.logError.apply(otherLogger, arguments);
console.error.apply(console, arguments);
}
}
});
```
--------------------------------
### IP Support
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Provides normalization and parsing support for IPv4 and IPv6 addresses within URIs.
```APIDOC
## IP Support
### Description
Provides normalization and parsing support for IPv4 and IPv6 addresses within URIs, including zone identifiers.
### Methods
- **URI.normalize(uri)**: Can normalize IPv4 and IPv6 addresses within a URI.
- **URI.parse(uri)**: Can parse URIs containing IPv6 addresses with zone identifiers.
### Examples
#### IPv4 Normalization
```javascript
URI.normalize("//192.068.001.000")
// returns: "//192.68.1.0"
```
#### IPv6 Normalization
```javascript
URI.normalize("//[2001:0:0DB8::0:0001]")
// returns: "//[2001:0:db8::1]"
```
#### IPv6 Zone Identifier Support
```javascript
URI.parse("//[2001:db8::7%25en1]");
// returns:
// {
// host : "2001:db8::7%en1"
// }
```
```
--------------------------------
### punycode.ucs2.encode(codePoints)
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/punycode/README.md
Creates a string based on an array of numeric code point values.
```APIDOC
## punycode.ucs2.encode(codePoints)
### Description
Creates a string based on an array of numeric code point values.
### Parameters
#### Path Parameters
- **codePoints** (Array) - Required - An array of numeric code point values.
### Request Example
```javascript
punycode.ucs2.encode([0x61, 0x62, 0x63]);
// → 'abc'
punycode.ucs2.encode([0x1D306]);
// → '\uD834\uDF06'
```
```
--------------------------------
### .getKeyword(String keyword)
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Retrieves the definition of a custom keyword. Returns `true` for built-in keywords and `false` if the keyword is not found.
```APIDOC
## .getKeyword(String keyword)
### Description
Returns custom keyword definition, `true` for pre-defined keywords and `false` if the keyword is unknown.
```
--------------------------------
### Convert Punycode domain/email to Unicode
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/punycode/README.md
Use `punycode.toUnicode` to convert Punycode-encoded domain names or email addresses to their Unicode equivalents. It only converts Punycode parts.
```javascript
punycode.toUnicode('xn--maana-pta.com');
// → 'mañana.com'
punycode.toUnicode('xn----dqo34k.com');
// → '☃-⌘.com'
// decode email addresses
punycode.toUnicode('джумла@xn--p-8sbkgc5ag7bhce.xn--ba-lmcq');
// → 'джумла@джpумлатест.bрфa'
```
--------------------------------
### URI.resolve
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Resolves a relative URI against a base URI.
```APIDOC
## URI.resolve
### Description
Resolves a relative URI against a base URI.
### Method
`URI.resolve(baseURI, relativeURI)`
### Parameters
- **baseURI** (string) - The base URI.
- **relativeURI** (string) - The relative URI to resolve.
### Response
The resolved URI string.
### Request Example
```javascript
URI.resolve("uri://a/b/c/d?q", "../../g")
```
### Response Example
```javascript
"uri://a/g"
```
```
--------------------------------
### compile
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Compiles a JSON schema into a validating function and caches it for future use. The generated function returns a boolean and has `errors` and `schema` properties.
```APIDOC
## .compile(Object schema)
### Description
Generates a validating function from a JSON schema and caches it. The returned function validates data against the schema. Schema validation against meta-schema is performed unless `validateSchema` option is false.
### Parameters
#### Schema
- **schema** (Object) - The JSON schema to compile.
### Returns
- **Function<Object data>** - A validating function that returns a boolean. It has `errors` and `schema` properties.
```
--------------------------------
### .addFormat
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Adds a custom format for validating strings or numbers, or replaces pre-defined formats. The format can be specified as a string, RegExp, function, or an object with `validate`, `compare`, and `async` properties.
```APIDOC
## .addFormat(String name, String|RegExp|Function|Object format)
### Description
Adds a custom format to validate strings or numbers. This method can also be used to replace pre-defined formats for an Ajv instance. Strings are converted to RegExp. A function should return a boolean validation result. If an object is passed, it should include `validate`, `compare`, and `async` properties.
- `validate`: A string, RegExp, or function for validation.
- `compare`: An optional comparison function for `formatMaximum`/`formatMinimum` keywords.
- `async`: A boolean indicating if `validate` is an asynchronous function.
- `type`: The type of data the format applies to (`string` or `number`).
Custom formats can also be added via the `formats` option.
### Method
`addFormat`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
* **name** (String) - The name of the format to add.
* **format** (String|RegExp|Function|Object) - The format definition. Can be a string, RegExp, function, or an object with `validate`, `compare`, and `async` properties.
```
--------------------------------
### Convert Unicode domain/email to Punycode
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/punycode/README.md
Use `punycode.toASCII` to convert Unicode domain names or email addresses to their Punycode ASCII representation. It only converts non-ASCII parts.
```javascript
punycode.toASCII('mañana.com');
// → 'xn--maana-pta.com'
punycode.toASCII('☃-⌘.com');
// → 'xn----dqo34k.com'
// encode email addresses
punycode.toASCII('джумла@джpумлатест.bрфa');
// → 'джумла@xn--p-8sbkgc5ag7bhce.xn--ba-lmcq'
```
--------------------------------
### Add Meta Schema
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Adds a meta-schema for validating other schemas. Draft-07 meta-schema is added by default.
```javascript
ajv.addMetaSchema(metaSchema);
```
--------------------------------
### Define Custom Range Keywords with Ajv
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Demonstrates defining 'range' and 'exclusiveRange' custom keywords using Ajv's `addKeyword` method with a compilation function. This allows for custom number validation logic within JSON schemas.
```javascript
ajv.addKeyword('range', {
type: 'number',
compile: function (sch, parentSchema) {
var min = sch[0];
var max = sch[1];
return parentSchema.exclusiveRange === true
? function (data) { return data > min && data < max; }
: function (data) { return data >= min && data <= max; }
}
});
var schema = { "range": [2, 4], "exclusiveRange": true };
var validate = ajv.compile(schema);
console.log(validate(2.01)); // true
console.log(validate(3.99)); // true
console.log(validate(2)); // false
console.log(validate(4)); // false
```
--------------------------------
### Validate Schema Security with json-schema-secure
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Use the provided meta-schema to validate your JSON schemas and ensure they adhere to security recommendations, preventing potential performance issues or vulnerabilities.
```javascript
const isSchemaSecure = ajv.compile(require('ajv/lib/refs/json-schema-secure.json'));
const schema1 = {format: 'email'};
isSchemaSecure(schema1); // false
const schema2 = {format: 'email', maxLength: MAX_LENGTH};
isSchemaSecure(schema2); // true
```
--------------------------------
### Assigning Defaults to Array Items
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Shows how `useDefaults: true` assigns a default value to a missing item in an array based on the schema defined for `items`. The original data array is modified.
```javascript
var schema = {
"type": "array",
"items": [
{ "type": "number" },
{ "type": "string", "default": "foo" }
]
}
var data = [ 1 ];
var validate = ajv.compile(schema);
console.log(validate(data)); // true
console.log(data); // [ 1, "foo" ]
```
--------------------------------
### addSchema
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Adds one or more schemas to the validator instance. Schemas are validated but not compiled immediately. They can be referenced later.
```APIDOC
## .addSchema(Array<Object>|Object schema [, String key])
### Description
Adds schema(s) to the validator instance. Schemas are validated against meta-schema by default. They can be referenced by their ID or an optional key.
### Parameters
#### Schema
- **schema** (Array<Object>|Object) - A single schema object or an array of schema objects.
#### Key
- **key** (String) - An optional key to reference the schema. If not provided, the schema's `id` is used.
### Returns
- **Ajv** - The Ajv instance, allowing for method chaining.
```
--------------------------------
### Custom Value Sorting with fast-json-stable-stringify
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/fast-json-stable-stringify/README.md
Demonstrates using a custom comparison function to sort object values in reverse numerical order. This custom sorting logic influences the final string representation.
```javascript
var stringify = require('fast-json-stable-stringify');
var obj = { d: 6, c: 5, b: [{z:3,y:2,x:1},9], a: 10 };
var s = stringify(obj, function (a, b) {
return a.value < b.value ? 1 : -1;
});
console.log(s);
```
--------------------------------
### Parse IPv6 with Zone Identifier
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/uri-js/README.md
Parses a URI containing an IPv6 address with a zone identifier, extracting the host component correctly.
```javascript
//IPv6 zone identifier support
URI.parse("//[2001:db8::7%25en1]");
//returns:
//{
// host : "2001:db8::7%en1"
//}
```
--------------------------------
### .getSchema
Source: https://github.com/nordicsemi/bluetooth-numbers-database/blob/master/node_modules/ajv/README.md
Retrieves a compiled schema that was previously added using `addSchema`. The schema can be accessed either by the key provided during addition or by its full reference (ID). The returned function includes a `schema` property pointing to the original schema.
```APIDOC
## .getSchema(String key)
### Description
Retrieves a compiled schema previously added with `addSchema` using the key provided to `addSchema` or its full reference (id). The returned validating function has a `schema` property with a reference to the original schema.
### Method
`getSchema`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
* **key** (String) - The key or full reference (id) of the schema to retrieve.
```