Registry / testing / influx-point-formatter

influx-point-formatter

JSON →
library1.0.0jsnpmunverified

A simple TypeScript library for formatting data points into the line protocol format used by InfluxDB. Current stable version is 1.0.0, released as a single version without active updates. It provides a PointFormatter class to convert key-value measurements with optional tags and timestamps into InfluxDB-compatible strings. Minimalistic and focused on formatting only, unlike full InfluxDB client libraries.

npm install influx-point-formatter
INSTALL
IMPORT
SIG · INFLUX-POINT-FORMA
I
influx-point-formatter
testingjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PointFormatter
import { PointFormatter } from 'influx-point-formatter'
Named export only; no default export exists.
PointFormatter (CommonJS)
const { PointFormatter } = require('influx-point-formatter')
const PointFormatter = require('influx-point-formatter')
Requires destructuring to access the named export.
PointFormatter type
import type { PointFormatter } from 'influx-point-formatter'
import { PointFormatter } from 'influx-point-formatter'
For type annotations only, use 'import type' to avoid runtime overhead.

Creates a PointFormatter instance for a CPU measurement with tags and fields, then formats it to InfluxDB line protocol string with nanosecond timestamp.

import { PointFormatter } from 'influx-point-formatter'; const formatter = new PointFormatter({ measurement: 'cpu', tags: { host: 'server01' }, fields: { value: 0.64 }, timestamp: Date.now() * 1e6 // nanoseconds }); console.log(formatter.format()); // Output: cpu,host=server01 value=0.64 1640995200000000000
Debug
Known issues
gotchaTimestamp must be in nanoseconds. Using milliseconds will produce incorrect timestamps.
fix
Convert milliseconds to nanoseconds by multiplying by 1e6 before passing to the formatter.
affects: >=1.0.0
gotchaField values must be numbers or strings. Objects or arrays will cause runtime errors.
fix
Only pass number or string values in the fields object.
affects: >=1.0.0
gotchaTags and fields are flattened; nested objects are not supported.
fix
Use flat key-value pairs for tags and fields.
affects: >=1.0.0
gotchaSpaces and commas in tag or field keys/values may break the line protocol format if not escaped.
fix
Escape special characters manually or ensure they are not present.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'format')
PointFormatter instance not created correctly, e.g., using default import instead of named.
fix
Use correct import: import { PointFormatter } from 'influx-point-formatter'
Error: Invalid timestamp value
Timestamp is not a number or is in milliseconds instead of nanoseconds.
fix
Ensure timestamp is a number representing nanoseconds since epoch.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
influx-point-formatter — npm install influx-point-formatter · libregistry