Comparing version 5.0.2 to 6.0.0
14
cli.js
#!/usr/bin/env node | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
import readline from 'node:readline' | ||
import { flatten } from './index.js' | ||
const fs = require('fs') | ||
const path = require('path') | ||
const readline = require('readline') | ||
const flat = require('./index') | ||
const filepath = process.argv.slice(2)[0] | ||
@@ -14,3 +12,3 @@ if (filepath) { | ||
fs.accessSync(file, fs.constants.R_OK) // allow to throw if not readable | ||
out(require(file)) | ||
out(JSON.parse(fs.readFileSync(file))) | ||
} else if (process.stdin.isTTY) { | ||
@@ -31,3 +29,3 @@ usage(0) | ||
function out (data) { | ||
process.stdout.write(JSON.stringify(flat(data), null, 2)) | ||
process.stdout.write(JSON.stringify(flatten(data), null, 2)) | ||
} | ||
@@ -34,0 +32,0 @@ |
15
index.js
@@ -1,5 +0,1 @@ | ||
module.exports = flatten | ||
flatten.flatten = flatten | ||
flatten.unflatten = unflatten | ||
function isBuffer (obj) { | ||
@@ -16,3 +12,3 @@ return obj && | ||
function flatten (target, opts) { | ||
export function flatten (target, opts) { | ||
opts = opts || {} | ||
@@ -55,3 +51,3 @@ | ||
function unflatten (target, opts) { | ||
export function unflatten (target, opts) { | ||
opts = opts || {} | ||
@@ -78,3 +74,4 @@ | ||
opts.object | ||
) ? key | ||
) | ||
? key | ||
: parsedKey | ||
@@ -145,3 +142,5 @@ } | ||
typeof key2 === 'number' && | ||
!opts.object ? [] : {} | ||
!opts.object | ||
? [] | ||
: {} | ||
) | ||
@@ -148,0 +147,0 @@ } |
{ | ||
"name": "flat", | ||
"version": "5.0.2", | ||
"main": "index.js", | ||
"bin": "cli.js", | ||
"version": "6.0.0", | ||
"type": "module", | ||
"bin": { | ||
"flat": "cli.js" | ||
}, | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
} | ||
} | ||
}, | ||
"files": [ | ||
"cli.js", | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"sideEffects": false, | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"scripts": { | ||
"test": "mocha -u tdd --reporter spec && standard cli.js index.js test/index.js" | ||
"test": "mocha -u tdd --reporter spec && standard cli.js index.js test/test.js" | ||
}, | ||
@@ -12,9 +31,5 @@ "license": "BSD-3-Clause", | ||
"devDependencies": { | ||
"mocha": "~8.1.1", | ||
"standard": "^14.3.4" | ||
"mocha": "^10.0.0", | ||
"standard": "^17.0.0" | ||
}, | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"dependencies": {}, | ||
"repository": { | ||
@@ -33,3 +48,3 @@ "type": "git", | ||
], | ||
"author": "Hugh Kennedy <hughskennedy@gmail.com> (http://hughskennedy.com)", | ||
"author": "Hugh Kennedy <hughskennedy@gmail.com> (https://hughsk.io)", | ||
"bugs": { | ||
@@ -36,0 +51,0 @@ "url": "https://github.com/hughsk/flat/issues" |
@@ -1,2 +0,2 @@ | ||
# flat [![Build Status](https://secure.travis-ci.org/hughsk/flat.png?branch=master)](http://travis-ci.org/hughsk/flat) | ||
# flat [![Build Status](https://github.com/hughsk/flat/actions/workflows/main.yml/badge.svg)](https://github.com/hughsk/flat/actions/workflows/main.yml) | ||
@@ -20,3 +20,3 @@ Take a nested Javascript object and flatten it, or unflatten an object with | ||
``` javascript | ||
var flatten = require('flat') | ||
import { flatten } from 'flat' | ||
@@ -42,6 +42,6 @@ flatten({ | ||
Flattening is reversible too, you can call `flatten.unflatten()` on an object: | ||
Flattening is reversible too, you can call `unflatten` on an object: | ||
``` javascript | ||
var unflatten = require('flat').unflatten | ||
import { unflatten } from 'flat' | ||
@@ -77,3 +77,3 @@ unflatten({ | ||
``` javascript | ||
var flatten = require('flat') | ||
import { flatten } from 'flat' | ||
@@ -146,3 +146,3 @@ flatten({ | ||
``` javascript | ||
var flatten = require('flat') | ||
import { flatten } from 'flat' | ||
@@ -171,4 +171,3 @@ flatten({ | ||
```javascript | ||
var flatten = require('flat') | ||
var unflatten = require('flat').unflatten | ||
import { flatten, unflatten } from 'flat' | ||
@@ -218,4 +217,3 @@ flatten({ | ||
`flat` is also available as a command line tool. You can run it with | ||
[`npx`](https://ghub.io/npx): | ||
`flat` is also available as a command line tool. You can run it with [`npx`](https://docs.npmjs.com/cli/v8/commands/npx): | ||
@@ -222,0 +220,0 @@ ```sh |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
Yes
12022
6
179
235
2