Skip to content

Commit

Permalink
feat: migrate to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Nov 11, 2022
1 parent 9f477dd commit 90ee0ce
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ or
### Usage

```js
const is_ip_private = require('private-ip')
import is_ip_private from 'private-ip'

is_ip_private('10.0.0.0')
// => true
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict'

module.exports = require('./lib').default
import is_ip_private from './lib/index.js'
export default is_ip_private
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "private-ip",
"version": "2.3.4",
"description": "Check if IP address is private.",
"main": "index.js",
"exports": "./index.js",
"type": "module",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
Expand Down Expand Up @@ -54,5 +55,8 @@
"ipaddr.js": "^2.0.1",
"@chainsafe/is-ip": "^2.0.1",
"netmask": "^2.0.2"
},
"engines": {
"node": ">=14.16"
}
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Netmask } from 'netmask'
import ip_regex from 'ip-regex'
import { isIP } from '@chainsafe/is-ip'
import { isValid as is_valid, parse, IPv4 } from 'ipaddr.js'
import ipaddr, { IPv4 } from 'ipaddr.js'
const { isValid: is_valid, parse } = ipaddr

const PRIVATE_IP_RANGES = [
'0.0.0.0/8',
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const test = require('ava')
const is_ip_private = require('./')
import test from 'ava'
import is_ip_private from './index.js'

const pub_ips = [
'44.37.112.180',
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"esModuleInterop": true,
"declaration": true
}
Expand Down

0 comments on commit 90ee0ce

Please sign in to comment.