Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide chunks store customization #11

Merged
merged 3 commits into from
Jun 12, 2024
Merged

feat: provide chunks store customization #11

merged 3 commits into from
Jun 12, 2024

Conversation

antongolub
Copy link
Member

@antongolub antongolub commented Jun 12, 2024

import {type TSpawnStore, $} from 'zurk'

const getFixedSizeArray = (size: number) => {
  const arr: any[] = []
  return new Proxy(arr, {
    get: (target: any, prop) =>
      prop === 'push' && arr.length >= size
        ? () => {}
        : target[prop]
  })
}
const store: TSpawnStore = {
  stdout: getFixedSizeArray(1),
  stderr: getFixedSizeArray(2),
  stdall: getFixedSizeArray(0)
}

const result = await $({store})`echo hello`
result.stdout // 'hello\n'
result.stdall // ''

@antongolub antongolub merged commit 3f78776 into main Jun 12, 2024
17 checks passed
@antongolub antongolub deleted the custom-store branch June 12, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant