Skip to content

Commit

Permalink
Update to v.0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
a-bentofreire committed Oct 13, 2024
1 parent 1c1aa56 commit e31dc6e
Show file tree
Hide file tree
Showing 29 changed files with 473 additions and 212 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
node_modules/
__tests__/
docs/
examples/
build.js
*.ts
.vscode/*
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
## v0.1.1 - 2024-10-13
- Improve build
- Add examples
- Improve README.md
- Guard c__ and d___ with try-finally

## v0.1.0 - 2024-10-12
- First release
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ And 2 optional functions:

If you find this project useful, please, read the [Support this Project](https://www.devtoix.com/en/projects/jstracetoix#support-this-project) on how to contribute.

This package is also available for Python on pypi.org as [PyTraceToIX](https://www.devtoix.com/en/projects/pytracetoix).
This package is also available for:
- Python on pypi.org as [PyTraceToIX](https://www.devtoix.com/en/projects/pytracetoix).

## Features

Expand Down Expand Up @@ -50,7 +51,7 @@ npm install jstracetoix --save-dev
<html lang="en">

<head>
<script src="https://raw.githubusercontent.com/a-bentofreire/jstracetoix/refs/heads/master/browser/jstracetoix.js"></script>
<script src="https://cdn.jsdelivr.net/gh/a-bentofreire/jstracetoix/browser/jstracetoix.js?v=0.1.1"></script>
<script>
d__(c__(5) + 1);
</script>
Expand Down
104 changes: 57 additions & 47 deletions browser/jstracetoix-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) 2024 Alexandre Bento Freire. All rights reserved.
// Licensed under the MIT license
// --------------------------------------------------------------------
// Version: 0.1.1
"use strict";
var jstracetoix = (() => {
var __defProp = Object.defineProperty;
Expand Down Expand Up @@ -114,18 +115,21 @@ var jstracetoix = (() => {
let displayName = typeof name === "function" ? name(index, Object.keys(inputs).length - metaCount, value) : name || `i${Object.keys(inputs).length - metaCount}`;
let displayValue = value;
let allowResult = allow;
if (typeof allow === "function") {
allowResult = allow(index, displayName, value);
if (typeof allowResult !== "boolean") {
displayValue = allowResult;
allowResult = true;
try {
if (typeof allow === "function") {
allowResult = allow(index, displayName, value);
if (typeof allowResult !== "boolean") {
displayValue = allowResult;
allowResult = true;
}
}
} finally {
if (allowResult === void 0 || allowResult) {
inputs[displayName] = displayValue;
}
inputs.index__ = index + 1;
releaseLock();
}
if (allowResult === void 0 || allowResult) {
inputs[displayName] = displayValue;
}
inputs.index__ = index + 1;
releaseLock();
return value;
};
var d__ = (value, params = {}) => {
Expand Down Expand Up @@ -156,49 +160,55 @@ var jstracetoix = (() => {
delete data.index__;
data.meta__ = data.meta__.filter((item) => item !== "index__");
data.allow_input_count__ = Object.keys(data).length - data.meta__.length + 1;
if (typeof allow === "function") {
allow = allow(data);
if (typeof allow !== "boolean") {
data[name] = allow;
allow = true;
}
}
if (allow !== false) {
format = format || _format;
let output = "";
if (_multithreading && format.thread) {
output += format.thread.replace("{id}", _threadNames[_threadId] || `${_threadId}`);
}
const replaceMacro = (_format2, _name, _value) => _format2.replace("{name}", _name).replace("{value}", typeof _value === "object" ? JSON.stringify(_value) : _value);
for (const key in data) {
if (!data.meta__.includes(key)) {
output += replaceMacro(format.input, key, data[key]) + format.sep;
try {
if (typeof allow === "function") {
allow = allow(data);
if (typeof allow !== "boolean") {
data[name] = allow;
allow = true;
}
}
if (format.result) {
output += replaceMacro(format.result, name, data[name]);
}
data.meta__ += ["output__"];
data.output__ = output;
if (before === void 0 || before(data)) {
output = data.output__ + (format.new_line ? "\n" : "");
if (false) {
_stream.write(output);
} else {
_stream(output);
if (allow !== false) {
format = format || _format;
let output = "";
if (_multithreading && format.thread) {
output += format.thread.replace("{id}", _threadNames[_threadId] || `${_threadId}`);
}
const replaceMacro = (_format2, _name, _value) => _format2.replace("{name}", _name).replace(
"{value}",
typeof _value === "object" ? JSON.stringify(_value) : _value
);
for (const key in data) {
if (!data.meta__.includes(key)) {
output += replaceMacro(format.input, key, data[key]) + format.sep;
}
}
if (format.result) {
output += replaceMacro(format.result, name, data[name]);
}
data.meta__ += ["output__"];
data.output__ = output;
if (before === void 0 || before(data)) {
output = data.output__ + (format.new_line ? "\n" : "");
if (false) {
_stream.write(output);
} else {
_stream(output);
}
}
} else {
data.allow__ = false;
}
} else {
data.allow__ = false;
}
after && after(data);
if (_inputsPerThreads[_threadId]) {
_inputsPerThreads[_threadId].pop();
if (_inputsPerThreads[_threadId].length === 0) {
delete _inputsPerThreads[_threadId];
after && after(data);
} finally {
if (_inputsPerThreads[_threadId]) {
_inputsPerThreads[_threadId].pop();
if (_inputsPerThreads[_threadId].length === 0) {
delete _inputsPerThreads[_threadId];
}
}
releaseLock();
}
releaseLock();
return value;
};
return __toCommonJS(jstracetoix_exports);
Expand Down
5 changes: 3 additions & 2 deletions browser/jstracetoix.js

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

Loading

0 comments on commit e31dc6e

Please sign in to comment.