Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hughsk/flat
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.0.0
Choose a base ref
...
head repository: hughsk/flat
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.0.1
Choose a head ref
  • 4 commits
  • 4 files changed
  • 2 contributors

Commits on Sep 15, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5d0a38c View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    85ab68a View commit details

Commits on Sep 19, 2023

  1. Fix broken exports field in package.json (#172)

    Co-authored-by: Jon Koops <jonkoops@gmail.com>
    JoeKarow and jonkoops authored Sep 19, 2023

    Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    3431170 View commit details
  2. 6.0.1

    jonkoops committed Sep 19, 2023

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    05ac9ca View commit details
Showing with 605 additions and 3,371 deletions.
  1. +2 −1 .github/dependabot.yml
  2. +584 −3,348 package-lock.json
  3. +5 −8 package.json
  4. +14 −14 test/test.js
3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -4,5 +4,6 @@ updates:
directory: /
open-pull-requests-limit: 999
rebase-strategy: disabled
versioning-strategy: widen
schedule:
interval: weekly
interval: daily
3,932 changes: 584 additions & 3,348 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{
"name": "flat",
"version": "6.0.0",
"version": "6.0.1",
"type": "module",
"bin": {
"flat": "cli.js"
},
"exports": {
".": {
"import": {
"types": "./index.d.ts",
"default": "./index.js"
}
"types": "./index.d.ts",
"default": "./index.js"
}
},
"files": [
@@ -23,13 +21,12 @@
"node": ">=18"
},
"scripts": {
"test": "mocha -u tdd --reporter spec && standard cli.js index.js test/test.js"
"test": "node --test && standard cli.js index.js test/test.js"
},
"license": "BSD-3-Clause",
"description": "Take a nested Javascript object and flatten it, or unflatten an object with delimited keys",
"devDependencies": {
"mocha": "^10.0.0",
"standard": "^17.0.0"
"standard": "^17.1.0"
},
"repository": {
"type": "git",
28 changes: 14 additions & 14 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* globals suite test */
import assert from 'node:assert'
import { exec } from 'node:child_process'
import { readFileSync } from 'node:fs'
import path from 'node:path'
import { describe, test } from 'node:test'
import { fileURLToPath } from 'node:url'
import { flatten, unflatten } from '../index.js'

@@ -18,7 +18,7 @@ const primitives = {
undefined
}

suite('Flatten Primitives', function () {
describe('Flatten Primitives', function () {
Object.keys(primitives).forEach(function (key) {
const value = primitives[key]

@@ -34,7 +34,7 @@ suite('Flatten Primitives', function () {
})
})

suite('Unflatten Primitives', function () {
describe('Unflatten Primitives', function () {
Object.keys(primitives).forEach(function (key) {
const value = primitives[key]

@@ -50,7 +50,7 @@ suite('Unflatten Primitives', function () {
})
})

suite('Flatten', function () {
describe('Flatten', function () {
test('Nested once', function () {
assert.deepStrictEqual(flatten({
hello: {
@@ -208,7 +208,7 @@ suite('Flatten', function () {
})
})

suite('Unflatten', function () {
describe('Unflatten', function () {
test('Nested once', function () {
assert.deepStrictEqual({
hello: {
@@ -359,7 +359,7 @@ suite('Unflatten', function () {
}))
})

suite('Overwrite + non-object values in key positions', function () {
describe('Overwrite + non-object values in key positions', function () {
test('non-object keys + overwrite should be overwritten', function () {
assert.deepStrictEqual(unflatten({ a: null, 'a.b': 'c' }, { overwrite: true }), { a: { b: 'c' } })
assert.deepStrictEqual(unflatten({ a: 0, 'a.b': 'c' }, { overwrite: true }), { a: { b: 'c' } })
@@ -380,7 +380,7 @@ suite('Unflatten', function () {
})
})

suite('.safe', function () {
describe('.safe', function () {
test('Should protect arrays when true', function () {
assert.deepStrictEqual(flatten({
hello: [
@@ -427,7 +427,7 @@ suite('Unflatten', function () {
})
})

suite('.object', function () {
describe('.object', function () {
test('Should create object instead of array when true', function () {
const unflattened = unflatten({
'hello.you.0': 'ipsum',
@@ -547,7 +547,7 @@ suite('Unflatten', function () {
})
})

suite('Arrays', function () {
describe('Arrays', function () {
test('Should be able to flatten arrays properly', function () {
assert.deepStrictEqual({
'a.0': 'foo',
@@ -587,7 +587,7 @@ suite('Arrays', function () {
})
})

suite('Order of Keys', function () {
describe('Order of Keys', function () {
test('Order of keys should not be changed after round trip flatten/unflatten', function () {
const obj = {
b: 1,
@@ -610,8 +610,8 @@ suite('Order of Keys', function () {
})
})

suite('CLI', function () {
test('can take filename', function (done) {
describe('CLI', function () {
test('can take filename', function (t, done) {
const cli = path.resolve(__dirname, '..', pkg.bin.flat)
const pkgJSON = path.resolve(__dirname, '..', 'package.json')
exec(`${cli} ${pkgJSON}`, (err, stdout, stderr) => {
@@ -621,7 +621,7 @@ suite('CLI', function () {
})
})

test('exits with usage if no file', function (done) {
test('exits with usage if no file', function (t, done) {
const cli = path.resolve(__dirname, '..', pkg.bin.flat)
const pkgJSON = path.resolve(__dirname, '..', 'package.json')
exec(`${cli} ${pkgJSON}`, (err, stdout, stderr) => {
@@ -631,7 +631,7 @@ suite('CLI', function () {
})
})

test('can take piped file', function (done) {
test('can take piped file', function (t, done) {
const cli = path.resolve(__dirname, '..', pkg.bin.flat)
const pkgJSON = path.resolve(__dirname, '..', 'package.json')
exec(`cat ${pkgJSON} | ${cli}`, (err, stdout, stderr) => {