Skip to content

Commit

Permalink
Merge pull request #7 from hildjj/add-todo
Browse files Browse the repository at this point in the history
Add todo
  • Loading branch information
hildjj committed Mar 14, 2024
2 parents b3766a9 + 6ce93d6 commit 33a17c4
Show file tree
Hide file tree
Showing 24 changed files with 1,162 additions and 514 deletions.
3 changes: 3 additions & 0 deletions .ncurc
@@ -0,0 +1,3 @@
{
"dep": ["prod", "dev", "packageManager"]
}
1 change: 1 addition & 0 deletions .npmignore
Expand Up @@ -18,3 +18,4 @@ TODO
tools/
tsconfig.json
tutorials/
.ncurc
25 changes: 21 additions & 4 deletions bin/basura.js
@@ -1,5 +1,4 @@
#!/usr/bin/env node
/* eslint-disable no-console */
#!/usr/bin/env -S node

import {Command, InvalidOptionArgumentError} from 'commander';
import {Basura} from '../lib/index.js';
Expand All @@ -13,11 +12,25 @@ const __dirname = path.dirname(__filename);

const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));

function myParseInt(value, dummyPrevious) {
function myParseInt(value, _prev) {
const v = parseInt(value, 10);
if (isNaN(v)) {
throw new InvalidOptionArgumentError('Not a number.');
}
if (v < 0) {
throw new InvalidOptionArgumentError('Must not be negative');
}
return v;
}

function myParse01(value, _prev) {
const v = parseFloat(value);
if (isNaN(v)) {
throw new InvalidOptionArgumentError('Not a number.');
}
if (v < 0 || v > 1) {
throw new InvalidOptionArgumentError('Must be between 0 and 1 inclusive');
}
return v;
}

Expand All @@ -32,6 +45,7 @@ const opts = program
.option('-b, --noBoxed', 'Do not generate boxed types, like String')
.option('-c, --cborSafe', 'Do not generate types that break CBOR')
.option('-d, --depth <number>', 'Maximum depth', myParseInt, 5)
.option('-e, --edgeFreq <number>', 'Edge case frequency', myParse01, 0.1)
.option('-j, --json', 'Output JSON')
.option('-o, --output <file>', 'File to output')
.option(
Expand Down Expand Up @@ -73,7 +87,10 @@ function main() {
util.inspect(obj, {
depth: Infinity,
colors: !opts.output && process.stdout.isTTY,
maxArrayLength: Infinity,
maxStringLength: Infinity,
});

let out = process.stdout;
if (opts.output) {
if (opts.output !== '-') {
Expand All @@ -85,7 +102,7 @@ function main() {
}
}
out.write(str);
out.write('\n');
out.end('\n');
}

main();
2 changes: 1 addition & 1 deletion docs/assets/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion docs/assets/style.css
Expand Up @@ -405,7 +405,8 @@ dd {
}
body {
background: var(--color-background);
font-family: "Segoe UI", sans-serif;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
font-size: 16px;
color: var(--color-text);
}
Expand Down

0 comments on commit 33a17c4

Please sign in to comment.