question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide searchSync and loadSync functions, instead of the sync option

See original GitHub issue

I was reviewing the documentation, then poking around in the code a little bit, wondering if things could be simplified —— and I’m thinking that the challenges we have in documenting and Flow-typing functions, because they can be sync or async based on an option, indicates a flaw that we should refactor out.

Instead of the sync option, we could have explorer.searchSync and explorer.loadSync functions. Internally, we’d do the same thing with our utility functions. I believe that the standard practice across Node is to provide separate functions for sync and async versions of the same behavior — instead of overloading a single function. This results in each function having a cleaner signature, which is easier to document, type check, unit test.

Does anybody object? If not, I will work on this refactoring and the new functions before our v5 release.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
davidtheclarkcommented, Mar 12, 2018

But should it be searchSync or search.sync?

I believe that the reason libraries go with fn (async) and fn.sync is because of how CommonJS works: that way the module can have one main export, the default function that people should use most of the time, instead of exporting an object. So you get fn and fn.sync instead of SomeModule.fn and SomeModule.fnSync.

That situation doesn’t apply to us, so I favor the searchSync convention.

0reactions
davidtheclarkcommented, May 5, 2018

Documented now in the v5 branch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cosmiconfig - npm
Find and load configuration from a package.json property, rc file, or CommonJS module. Latest version: 7.0.1, last published: a year ago.
Read more >
cosmiconfig/CHANGELOG.md at main - GitHub
Fixed: Allow searchSync and loadSync to load JS configuration files whose export is a Promise. 5.0.1. The API has been completely revamped to...
Read more >
Sign in & sync in Chrome - Android - Google Support
You can find and update your synced info on all your devices, like bookmarks, history, passwords, and other settings. You can sign in...
Read more >
node_modules/cosmiconfig · master - tbrousso - PLMlab - CNRS
Values in loaders are either a loader function (described below) or an object with sync and/or async properties, whose values are loader functions....
Read more >
svgr - core - node_modules - cosmiconfig - CHANGELOG.md
Fixed: Allow searchSync and loadSync to load JS configuration files ... The loaders option allows you specify custom functions to derive ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found