New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

poproxy

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poproxy

Proxy factory for preserving insertion order of object keys

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

poproxy

Preserved Order Proxy

poproxy is a Proxy constructor that preserves the original order of properties as they are assigned to the object, ignoring the exceptions that apply to numbers and symbols.

Example

import { preserveOrder } from "poproxy";

interface Foo {
  a: string;
  b: string;
  "0": string;
  "1": string;
}

const foo: Partial<Foo> = {};
const proxy = preserveOrder<Foo>(foo);

proxy.b = "b";
proxy[1] = "1";
proxy["0"] = "0";
proxy.a = "a";

Object.keys(foo); // ["0", "1", "b", "a"]
JSON.stringify(foo); // {"0":"0","1":"1","b":"b","a":"a"}

Object.keys(proxy); // ["b", "1", "0", "a"]
JSON.stringify(proxy); // {"b":"b","1":"1","0":"0","a":"a"}

Just like normal objects, if a property is deleted and then assigned, it will be appended rather than returning to its previous position:

delete proxy.b;
proxy.b = "B";

Object.keys(foo); // ["0", "1", "a", "b"]
JSON.stringify(foo); // {"0":"0","1":"1","a":"a","b":"B"}

Object.keys(proxy); // ["1", "0", "a", "b"]
JSON.stringify(proxy); // {"1":"1","0":"0","a":"a","b":"B"}

FAQs

Package last updated on 16 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts