Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flat

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flat - npm Package Compare versions

Comparing version 5.0.2 to 6.0.0

index.d.ts

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 @@

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc