Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
update todo
Browse files Browse the repository at this point in the history
  • Loading branch information
umutbasal committed Aug 13, 2022
1 parent a97dd2c commit 265e23c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions device-detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ func initContext() (*v8.Context, error) {
src = strings.TrimPrefix(src, `"use strict";`+"\n")
src = strings.TrimPrefix(src, "(() => {\n")
src = strings.TrimSuffix(src, "\n})();\n")

// Todo: take these from New_ functions nad run with native v8 apis. or export all funcs to global var with regexp replace.
src = src + "\n" + `DeviceDetector = new require_src()`
src = src + "\n" + `BotDetector = new require_bot()`
// src = src + "\n" + `ClientParser_ = new init_client()`
// src = src + "\n" + `DeviceParser = new init_device()`
// src = src + "\n" + `OperatingSystemParser_ = new init_operating_system2()`
// src = src + "\n" + `VendorFragmentParser_ = new init_vendor_fragment()`

ctx := v8.NewContext()
_, e := ctx.RunScript(src+"\n", "h.js")
Expand All @@ -36,6 +42,9 @@ func initContext() (*v8.Context, error) {
return ctx, nil
}

// TODO: clear duplicated code.
// TODO: use types.

// NewDeviceDetector creates a new device detector.
func NewDeviceDetector(options DeviceDetectorOptions) (parser Parser, err error) {
ctx, err := initContext()
Expand Down

0 comments on commit 265e23c

Please sign in to comment.