Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@blitz/monaco-auto-import
Advanced tools
Readme
Easily add auto-import to the Monaco editor, with Javascript & Typescript support.
import AutoImport, { regexTokeniser } from '@blitz/monaco-auto-import'
const editor = monaco.editor.create(document.getElementById('demo'), {
value: `
PAD
leftPad
rightPad
`,
language: 'typescript'
})
const completor = new AutoImport({ monaco, editor })
completor.imports.saveFiles([
{
path: './node_modules/left-pad/index.js',
aliases: ['left-pad'],
imports: regexTokeniser(`
export const PAD = ''
export function leftPad() {}
export function rightPad() {}
`)
}
])
yarn add @blitz/monaco-auto-import
# or
npm i @blitz/monaco-auto-import --save
Simply create a new Monaco editor instance and pass it to AutoImport
. This will register custom completion providers for Monaco's javascript
and typescript
language services.
import AutoImport from '@blitz/monaco-auto-import'
const editor = monaco.editor.create(document.getElementById('demo'), {
language: 'typescript'
})
const completor = new AutoImport({ monaco, editor })
To make the auto-importer aware of a file with exports, simply call completor.imports.saveFile
.
completor.imports.saveFile({
path: './src/my-app.js',
imports: [
{
type: 'const',
name: 'Testing'
}
]
})
This package includes a built-in regexTokeniser
, which uses a simple Regex to extracts exports from Javascript / Typescript code
import { regexTokeniser } from '@blitz/monaco-auto-import'
const imports = regexTokeniser(`
export const a = 1
export class Test {}
`)
// [{ type: 'const', name: 'a'}, { type: 'class', name: 'Test' }]
completor.imports.saveFile({
path: './src/my-app.js',
imports: imports
})
imports.saveFile(file: File): void
Saves a file to the internal store, making it available for completion
imports.saveFiles(files: File[]): void
Bulk-saves files to the internal store from an Array of files
imports.getFile(path: string): File
Fetches a file from the internal store by it's path name (or one of it's aliases).
imports.getImports(name: string): ImportObject[]
Returns all the imports that exactly match a given string.
imports.addImport(path: string, name: string, type?: Expression): boolean
Adds an import to a given file, with an optional type
paramater. Returns true if the file existed
imports.removeImport(path: string, name: string): boolean
Removes an import from a given file. Returns true if the file existed
FAQs
Easily add auto-import to the Monaco editor, with Javascript & Typescript support.
The npm package @blitz/monaco-auto-import receives a total of 11 weekly downloads. As such, @blitz/monaco-auto-import popularity was classified as not popular.
We found that @blitz/monaco-auto-import demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.