Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old dependencies #32

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
node_modules
dist
coverage
.nyc_output
.nyc_output
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.5.0.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.5.0.cjs
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
"array-flatten": "^2.1.2",
"dns-equal": "^1.0.0",
"fast-deep-equal": "^3.1.3",
"multicast-dns": "^7.2.5"
},
Expand Down Expand Up @@ -49,5 +47,9 @@
"bugs": {
"url": "https://github.com/onlxltd/bonjour-service/issues"
},
"homepage": "https://github.com/onlxltd/bonjour-service"
"homepage": "https://github.com/onlxltd/bonjour-service",
"packageManager": "[email protected]",
"engines": {
"node": ">=11.0.0"
}
}
2 changes: 1 addition & 1 deletion src/lib/browser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import KeyValue from './KeyValue'
import DnsTxt from './dns-txt'
import dnsEqual from 'dns-equal'
import dnsEqual from './utils/dns-equal'
import { EventEmitter } from 'events'
import Service, { ServiceRecord } from './service'
import { toString as ServiceToString, toType as ServiceToType } from './service-types'
Expand Down
5 changes: 2 additions & 3 deletions src/lib/mdns-server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import flatten from 'array-flatten'
import { ServiceRecord } from './service'
import deepEqual from 'fast-deep-equal/es6'

import MulticastDNS from 'multicast-dns'
import dnsEqual from 'dns-equal'
import dnsEqual from './utils/dns-equal'

export class Server {

Expand Down Expand Up @@ -66,7 +65,7 @@ export class Server {

// generate the answers section
var answers = type === 'ANY'
? flatten.depth(Object.keys(self.registry).map(self.recordsFor.bind(self, name)), 1)
? Object.keys(self.registry).map(self.recordsFor.bind(self, name)).flat(1)
: self.recordsFor(name, type)

if (answers.length === 0) return
Expand Down
7 changes: 3 additions & 4 deletions src/lib/registry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import flatten from 'array-flatten'
import dnsEqual from 'dns-equal'
import dnsEqual from './utils/dns-equal'
import Server from './mdns-server'
import Service, { ServiceConfig, ServiceRecord } from './service'

Expand Down Expand Up @@ -167,14 +166,14 @@ export class Registry {

services = services.filter((service: Service) => service.activated) // ignore services not currently starting or started

var records: any = flatten.depth(services.map(function (service) {
var records: any = services.flatMap(function (service) {
service.activated = false
var records = service.records()
records.forEach((record: ServiceRecord) => {
record.ttl = 0 // prepare goodbye message
})
return records
}), 1)
})

if (records.length === 0) return callback && callback()
server.unregister(records)
Expand Down
13 changes: 13 additions & 0 deletions src/lib/utils/dns-equal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

const capitalLetterRegex : RegExp = /[A-Z]/g

function toLowerCase(input: string) {
return input.toLowerCase()
}

export default function dnsEqual(a: string, b: string) : boolean {
const aFormatted = a.replace(capitalLetterRegex, toLowerCase)
const bFormatted = b.replace(capitalLetterRegex, toLowerCase)

return aFormatted === bFormatted
}
4 changes: 0 additions & 4 deletions types/dns-equal.d.ts

This file was deleted.

Loading