|
| 1 | +# @nyamathshaik/fast-json-patch |
| 2 | + |
| 3 | +## ⚠️ Temporary Fork Notice |
| 4 | + |
| 5 | +This is a **temporary fork** of [fast-json-patch](https://github.com/Starcounter-Jack/JSON-Patch) with added Date object support. |
| 6 | + |
| 7 | +### Why This Fork Exists |
| 8 | + |
| 9 | +- **PR Submitted**: [#330](https://github.com/Starcounter-Jack/JSON-Patch/pull/330) |
| 10 | +- **Status**: Waiting for merge into official package |
| 11 | +- **Purpose**: Use Date support immediately while PR is under review |
| 12 | + |
| 13 | +### What's Different |
| 14 | + |
| 15 | +This fork adds native Date object support: |
| 16 | +- Date objects are preserved during cloning (not converted to strings) |
| 17 | +- Date objects are compared by value, not reference |
| 18 | +- Patches contain actual Date objects, not ISO strings |
| 19 | + |
| 20 | +### Installation |
| 21 | + |
| 22 | +```bash |
| 23 | +npm install @nyamathshaik/fast-json-patch |
| 24 | +``` |
| 25 | + |
| 26 | +### Usage |
| 27 | + |
| 28 | +Same API as original fast-json-patch, but now works with Date objects: |
| 29 | + |
| 30 | +```javascript |
| 31 | +const { compare } = require('@nyamathshaik/fast-json-patch'); |
| 32 | + |
| 33 | +const obj1 = { |
| 34 | + event: { |
| 35 | + startTime: new Date('2025-11-11T10:00:00Z') |
| 36 | + } |
| 37 | +}; |
| 38 | + |
| 39 | +const obj2 = { |
| 40 | + event: { |
| 41 | + startTime: new Date('2025-11-11T11:00:00Z') |
| 42 | + } |
| 43 | +}; |
| 44 | + |
| 45 | +const patches = compare(obj1, obj2); |
| 46 | +console.log(patches); |
| 47 | +// [{ op: 'replace', path: '/event/startTime', value: Date(...) }] |
| 48 | +// ^ Date object preserved! |
| 49 | +``` |
| 50 | + |
| 51 | +### Migration Plan |
| 52 | + |
| 53 | +**When the official PR is merged:** |
| 54 | + |
| 55 | +1. Update `package.json`: |
| 56 | + ```json |
| 57 | + { |
| 58 | + "dependencies": { |
| 59 | + "fast-json-patch": "^3.2.0" // or whatever version includes Date support |
| 60 | + } |
| 61 | + } |
| 62 | + ``` |
| 63 | + |
| 64 | +2. Remove this scoped package: |
| 65 | + ```bash |
| 66 | + npm uninstall @nyamathshaik/fast-json-patch |
| 67 | + npm install fast-json-patch |
| 68 | + ``` |
| 69 | + |
| 70 | +3. No code changes needed! API is identical. |
| 71 | + |
| 72 | +### Version Numbering |
| 73 | + |
| 74 | +- **Base**: `3.1.1` (official fast-json-patch version) |
| 75 | +- **Fork**: `3.1.2-date-support.0` |
| 76 | +- **Suffix**: `-date-support.X` indicates this is a temporary fork |
| 77 | + |
| 78 | +### Links |
| 79 | + |
| 80 | +- **Official Package**: https://www.npmjs.com/package/fast-json-patch |
| 81 | +- **This Fork**: https://github.com/nyamathshaik/JSON-Patch/tree/feature/date-object-support |
| 82 | +- **PR**: https://github.com/Starcounter-Jack/JSON-Patch/pull/330 |
| 83 | + |
| 84 | +### License |
| 85 | + |
| 86 | +MIT (same as original) |
| 87 | + |
| 88 | +### Credits |
| 89 | + |
| 90 | +- Original Author: Joachim Wester |
| 91 | +- Date Support: Nyamath Shaik |
| 92 | +- Generated with: Claude Code |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +**Note**: This package will be deprecated once the official package merges Date support. |
0 commit comments