midrissi / Func Loc
Licence: mit
A simple tool that helps you to retrieve the function location from its reference.
Stars: â 99
Programming Languages
javascript
184084 projects - #8 most used programming language
typescript
32286 projects
Projects that are alternatives of or similar to Func Loc
React Hook Mighty Mouse
đ React hook that tracks mouse events on selected element - zero dependencies
Stars: â 75 (-24.24%)
Mutual labels: location
Location
Smartphone navigation positionning, fusion GPS and IMU sensors.
Stars: â 87 (-12.12%)
Mutual labels: location
Shellfuncs
Python API to execute shell functions as they would be Python functions
Stars: â 96 (-3.03%)
Mutual labels: function
Unix Text Commands
Unix Text Processing Command Reference
Stars: â 78 (-21.21%)
Mutual labels: reference
Kotlin Reference Chinese
Kotlin ĺŽćšć楣ďźĺčé¨ĺďźä¸ćç
Stars: â 85 (-14.14%)
Mutual labels: reference
Leaflet Gps
Simple leaflet control plugin for tracking gps position
Stars: â 90 (-9.09%)
Mutual labels: location
Uinspector
A UI inspector to traverse a view hierarchy on Android
Stars: â 97 (-2.02%)
Mutual labels: inspector
Geo Location
Web component element for the Geolocation API
Stars: â 86 (-13.13%)
Mutual labels: location
Python Cheatsheet
Basic Cheat Sheet for Python (PDF, Markdown and Jupyter Notebook)
Stars: â 1,334 (+1247.47%)
Mutual labels: reference
Locationhelper
Android library project that helps you to track user location and manage the updates.
Stars: â 79 (-20.2%)
Mutual labels: location
P5.geolocation
a geolocation and geofencing library for p5.js
Stars: â 75 (-24.24%)
Mutual labels: location
Whereareyou
Real time location tracker using Android App & Firebase with Mapbox
Stars: â 96 (-3.03%)
Mutual labels: location
Checklist Tools Website
đż The perfect Checklist Website for meticulous developers.
Stars: â 73 (-26.26%)
Mutual labels: reference
Amr Tutorial
Abstract Meaning Representation (AMR) tutorial slides
Stars: â 89 (-10.1%)
Mutual labels: reference
Locokit
Location, motion, and activity recording framework for iOS
Stars: â 1,353 (+1266.67%)
Mutual labels: location
Reference En
Editable source for the Arduino Reference
Stars: â 97 (-2.02%)
Mutual labels: reference
Library
A collection of various articles and books I've are worth revisiting.
Stars: â 93 (-6.06%)
Mutual labels: reference
func-loc
A simple tool that help you to retrieve the function location from its reference.
How to install
$ npm i func-loc
How to use
const { locate } = require('func-loc');
const fn = () => {
console.log('Hello there');
};
(async () => {
const result = await locate(fn);
console.log(result);
// Will result: { source: 'file://__BASE_FOLDER__/func-loc/this-file.js', line: 3, column: 12 }
})();
APIs
-
locate(fn: Function)
: Will retrieve the location of a given function, and will cache it so that the second call will be faster.
The result of the call will be an object that contains these attributes:
-
source
: The source file. -
line
: The line where the function was defined. -
column
: The exact column where the function was declared.
Internally, this function will open an inspector session. So it is always a good idea to call the disconnect
method when you are done.
-
disconnect()
: willdisconnect
the inspector session, cleans the cache and delete temporary created objects from the global object.
Using Source Maps
This library can also locate the original code using source-map:
Lets say that you have a typescript file containing:
// File: `module.ts`
export function inner() {
const fn3 = () => {};
return fn3;
}
Transpiling this file using typescript compiler will generate a source map file like:
{
"origin": {
"path": "/BASE_FOLDER/module.js",
"column": 24,
"line": 5,
"source": "file:///BASE_FOLDER/module.js"
},
"line": 3,
"column": 14,
"path": "/BASE_FOLDER/module.ts",
"source": "file:///BASE_FOLDER/module.ts"
}
And a javascript file containing:
"use strict";
exports.__esModule = true;
// File: `module.ts`
function inner() {
var fn3 = function () { };
return fn3;
}
exports.inner = inner;
//# sourceMappingURL=module.js.map
If you execute the following code
const { locate } = require('func-loc');
const { inner } = require('../__tests__/assets/module');
(async () => {
const loc = await locate(inner(), { sourceMap: true });
console.log(loc);
})();
It will output the line of the inner function f3 of the file module.ts
:
{
"origin": {
"path": "/BASE_FOLDER/module.js",
"column": 24,
"line": 5,
"source": "file:///BASE_FOLDER/module.js"
},
"line": 3,
"column": 14,
"path": "/BASE_FOLDER/module.ts",
"source": "file:///BASE_FOLDER/module.ts"
}
License
MIT Š Mohamed IDRISSI
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].