0.0.1 • Published 5 years ago

@mitsuru793/snippet-executor v0.0.1

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

Snippet-Executor

This is a closure manager. It's useful when you write some code brocks in one file. You don't have to split the file.

import Codes from 'codes'

const lessons = new Codes()
lessons.push('join array', () => {
  const nums = [1]
  nums.join([2])
  console.log(nums)
})

lessons.push('join string', () => {
  const nums = '1'
  nums += 2
  console.log(nums)
})

lessons.runLast()
// execute 'join string'
// => 12

Methods

push(code: Function): this
push(title: string, code: Function): this

runAt(index: number | string, args: any[] = []): any
runFirst(args: any[] = []): any
runLast(args: any[] = []): any {
runMatch(pattern: RegExp, args: any[] = []): any