Elm packages information library.
npm i elm-packages
const elmInfo = require('elm-packages')
// Inside an async function
const allPackages = await elmInfo.packages()
const elmInfo = require('elm-packages')
// Inside an async function
const docs = await elmInfo.info('elm','browser','1.0.1')
const elmInfo = require('elm-packages')
// Inside an async function
const docs = await elmInfo.version('elm','browser')
This package uses an offline db (db.json
~ 24MB) to provide Elm type info (npm compresses all packages by default so the download size would be < 3.5 MB) and uses an in memory Map
indexed by methods
and unions
so queries would be resolved super fast.
You can pass an options
object alongside keyword
to customize your search. Structure of options
object is:
{
method: String
packages: Array
type: String
}
method
: How to match keyword. Valid options are:exact
: Results should be exactly the same as searchkeyword
.startsWith
: Results should be started with searchkeyword
.contains
:keyword
can appear anywhere in searched entries.
packages
: Array ofstring
. Array of all packages to search for keyword. Empty array means all packages.type
: What to search. Valid options are:method
: Searchkeyword
in methods.union
: Searchkeyword
in unions.any
: Searchkeyword
in methods and unions.
Search result is an object of:
{
Methods: [],
Unions: []
}
search('toUpper')
search('toUpper',
{
method: 'exact',
packages: [ 'NoRedInk/elm-formatted-text-19' ],
type: 'method'
}
)
search('to',
{
method: 'startsWith',
packages: [ 'elm/core', 'NoRedInk/elm-formatted-text-19' ],
type: 'method'
}
)
search('fun',
{
method: 'contains',
packages: [],
type: 'method'
}
)
search('Error',
{
method: 'exact',
packages: [],
type: 'union'
}
)
PRs are welcome. Check if tests pass by npm run test
- Fixing security vulnerability in
js-yaml
dependency. - Fixing security vulnerability in
handlebars
dependency.
- Search options added with examples.
- Error in case of malformed Json.
- Unit tests added.
- Search added.
- Create offline db.
- Get latest package version info by default.
- Initial release.