internet-number
Fetch and parse APNIC delegated internet number resources
Last updated 3 years ago by blackglory .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install internet-number 
SYNC missed versions from official npm registry.

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[]
}

Current Tags

  • 2.2.1                                ...           latest (4 months ago)

7 Versions

  • 2.2.1                                ...           4 months ago
  • 2.2.0                                ...           5 months ago
  • 2.1.0                                ...           5 months ago
  • 2.0.0                                ...           5 months ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (7)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |