Miss any of our Open RFC calls?Watch the recordings here! »

internet-number

2.2.1 • Public • Published

internet-number npm GitHub license

Utility for fethcing and parsing latest statistics files from RIR

Installation

yarn add internet-number
// Constant
import { Domian, Registry } from 'internet-number'
 
// Downloader
import { downloadLatestStatisticsFile } from 'internet-number'
 
// Fetcher
import { fetchLatestChecksum, fetchLatestStatisticsFile } from 'internet-number'
 
// Parser
import {
  parseStatisticsFile, parseFormat, parseFomratAsync
  isVersion, isSummary, isRecord
} from 'internet-number'
 
// Exception
import { ChecksumIncorrectError, UnknownChecksumError } from 'internet-number'

Usage

const filename = await downloadLatestStatisticsFile(Domian.AFRINIC, Registry.AFRINIC, '/tmp/latest')
 
for await (const value of parseStatisticsFile(filename)) {
  if (isVersion(value)) ...
  if (isSummary(value)) ...
  if (isRecord(value)) ...
}

API

  • function downloadLatestStatisticsFile(domain: Domain, registry: Registry, filename: string): Promise<string>
  • function fetchLatestChecksum(domain: Domain, registry: Registry): Promise<string>
  • function fetchLatestStatisticsFile(domain: Domain, registry: Registry): Promise<NodeJS.ReadableStream>
  • function parseStatisticsFile(filename: string): AsyncIterable<IVersion | ISummary | IRecord>
  • function parseFormat(lines: Iterable<string>): Iterable<IVersion | ISummary | IRecord>
  • function parseFormatAsync(lines: AsyncIterable<string>): AsyncIterable<IVersion | ISummary | IRecord>
  • function isVersion(val: IVersion | ISummary | IRecord): boolean
  • function isSummary(val: IVersion | ISummary | IRecord): boolean
  • function isRecord(val: IVersion | ISummary | IRecord): boolean

Structure

interface IVersion {
  version: string
  registry: string
  serial: string
  records: string
  startdate: string
  enddate: string
  UTCoffset: string
}
 
interface ISummary {
  registry: string
  type: string
  count: string
  summary: string
}
 
interface IRecord {
  registry: string
  cc: string
  type: string
  start: string
  value: string
  date: string
  status: string
  extensions: string[]
}

Keywords

none

Install

npm i internet-number

DownloadsWeekly Downloads

3

Version

2.2.1

License

MIT

Unpacked Size

50.1 kB

Total Files

39

Last publish

Collaborators

  • avatar