1.0.0 • Published 10 months ago

fnlocation v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Getting the location of a function in a file in Node

Usage

// src/test/test.js
import fnlocation from 'fnlocation'

const sayHello = function () { console.log('hello') }

const sayHelloPath = await fnlocation.scriptPath(sayHello)
console.log(sayHelloPath)
// {
//   column: 1,
//   line: 3,
//   path: '/you/path/src/test.test.js'
//   source: 'file:///you/path/src/test.test.js'
// }

When the function location is no longer queried, call the clean method to release all remote objects

// ...
;(async () => {
  await fnlocation.clean()
// ...
})()

You can initialize it by calling the init method when you query it again.

// ...
;(async () => {
  fnlocation.init()

// ...
// await fnlocation.scriptPath(xxx)
})()
1.0.0

10 months ago