Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/FUNDING.yml

This file was deleted.

38 changes: 17 additions & 21 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
---
name: Bug report
about: Create a report to help us improve
about: Report a bug to help us improve
title: ''
labels: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.
A clear and concise description of the bug.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.
```javascript
// Minimal code example that reproduces the issue
import javaScriptToString from "@lopatnov/javascripttostring";

**Screenshots**
If applicable, add screenshots to help explain your problem.
const value = /* ... */;
const result = javaScriptToString(value);
// Expected: ...
// Actual: ...
```

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Expected behavior**
A clear description of what you expected to happen.

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Environment:**
- Node.js version: [e.g. 20.x]
- Package version: [e.g. 1.7.3]
- OS: [e.g. Windows 11, macOS 14]

**Additional context**
Add any other context about the problem here.
21 changes: 17 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
Thank you for your contribution to the JavaScriptToString repo.
Before submitting this PR, please make sure:
## Description

- [ ] Your code builds clean without any errors or warnings
- [ ] You have added unit tests
Brief description of the changes.

## Type of Change

- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Refactoring
- [ ] Other (describe below)

## Checklist

- [ ] Code builds clean without errors or warnings
- [ ] Tests have been added or updated
- [ ] All tests pass (`npm test`)
- [ ] Code style verified (`npm run check`)
28 changes: 18 additions & 10 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
name: Node CI

on: [push]
on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]
node-version: [18.x, 20.x, 22.x, 24.x]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm i
npm run build --if-present
npm test
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Lint and format check
run: npm run check

- name: Build
run: npm run build

- name: Test
run: npm test
env:
CI: true
29 changes: 18 additions & 11 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,29 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 12
node-version: 22
cache: 'npm'
- run: npm ci
- run: npm run check
- run: npm run build
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- run: npm run configure-npm
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: 22
registry-url: 'https://registry.npmjs.org'
- run: npm install
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
Expand All @@ -35,13 +39,16 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: 22
registry-url: 'https://npm.pkg.github.com'
scope: '@lopatnov'
cache: 'npm'
- run: npm run configure-gpr
- run: npm ci
- run: npm run build
- run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.GPR_PAT }}
NODE_AUTH_TOKEN: ${{ secrets.GPR_PAT }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ typings/

# next.js build output
.next
/.claude
3 changes: 0 additions & 3 deletions .jshintrc

This file was deleted.

6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"name": "Launch Tests",
"program": "${workspaceFolder}\\node_modules\\jest\\bin\\jest",
"args": [
"--debug"
"--runInBand",
"--no-cache"
],
"console": "integratedTerminal"
}
]
}
95 changes: 92 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,92 @@
Version 1.0.0 - 1.2.0
Added single default function javaScriptToString
See https://github.com/lopatnov/jsToString/tree/2ad125ef392d7db45b26e14ec3225f35f28aad41
# Changelog

All notable changes to this project will be documented in this file.

## [2.0.0] - 2026-02-14

### Added

- Cross-reference support: shared objects between different branches are now preserved as references
- `throwOnNonSerializable` option: throws an error for non-serializable values instead of returning `"undefined"`
- Explicit handling for non-serializable types: `Promise`, `Generator`, `WeakRef`, `WeakMap`, `WeakSet`, `FinalizationRegistry`
- Negative zero (`-0`) preserved correctly
- Sparse arrays preserved (holes are not filled with `undefined`)
- `Symbol.for()` registry symbols distinguished from regular symbols
- `Symbol("")` (empty description) distinguished from `Symbol()` (no description)
- RegExp `lastIndex` preserved when non-zero
- Error subclasses preserved: `TypeError`, `RangeError`, `ReferenceError`, `SyntaxError`, `URIError`, `EvalError`
- `Object.create(null)` objects supported
- Async functions and async generator functions supported
- `SharedArrayBuffer` supported (grouped with `ArrayBuffer`)
- ESM (`.mjs`) and CJS (`.cjs`) dual-package support via `exports` field
- UMD build for browsers
- `"type": "module"` in package.json
- Biome for linting and formatting (replaced JSHint)
- Jest coverage reporting enabled
- 191 tests total (up from 53)

### Fixed

- **Issue #1:** Circular references to parent elements at the top level are now resolved correctly
- Circular chain references (A -> B -> C -> A) now work at any depth
- `counter = counter++` post-increment bug in cross-reference actions (value never incremented)
- `Object.prototype.hasOwnProperty.call()` used instead of `value.hasOwnProperty()` to support null-prototype objects
- Non-identifier property names in function properties now use bracket notation (`fn["my-prop"]` instead of invalid `fn.my-prop`)
- Non-identifier property names in object literals are now quoted
- Invalid `Date` objects now serialize as `new Date(NaN)` instead of `new Date("null")`
- Date strings are now quoted in output

### Changed

- Cross-reference output uses dot notation when possible (`___ref1.prop` instead of `___ref1['prop']`)
- Internal IIFE variable renamed from `___j2s_` to `___ref` for readability
- Updated `@lopatnov/get-internal-type` to 2.0.0
- Updated all dependencies to latest versions
- Migrated from `rollup-plugin-*` to `@rollup/plugin-*` official packages
- Migrated CI from Node.js 12.x to Node.js 18/20/22/24
- Updated `@lopatnov/rollup-plugin-uglify` from 2.x to 3.x
- Upgraded TypeScript to 5.8, Jest to 30, Rollup to 4, Biome to 2.x
- tsconfig lib updated to ES2022
- Minimum Node.js version is now 18.0.0

### Removed

- Travis CI configuration (replaced by GitHub Actions)
- JSHint configuration (replaced by Biome)
- `rollup-plugin-sourcemaps` (deprecated, no longer needed)

## [1.7.3] - 2022

### Changed

- Updated terser dependency

## [1.7.0 - 1.7.2]

### Changed

- Updated packages and dependencies

## [1.5.0 - 1.6.0]

### Added

- Options for limiting nesting depth (`nestedObjectsAmount`, `nestedArraysAmount`, `nestedFunctionsAmount`)

## [1.3.0 - 1.4.0]

### Added

- Support for Map, Set, TypedArray, ArrayBuffer, DataView
- Support for BigInt, Symbol

## [1.0.0 - 1.2.0]

### Added

- Initial release with `javaScriptToString` function
- Support for primitives, objects, arrays, functions, Date, RegExp, Error
- Circular reference handling
- Function properties and prototype serialization

See [GitHub releases](https://github.com/lopatnov/jsToString/releases) for more details.
23 changes: 23 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,26 @@ Examples of unacceptable behavior by participants include:
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project owner. All complaints will be reviewed
and investigated and will result in a response that is deemed necessary and
appropriate to the circumstances.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
Loading