
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@lopatnov/namespace
Advanced tools
Dynamic namespace creation
npm install @lopatnov/namespace
<script src="//lopatnov.github.io/namespace/dist/namespace.min.js"></script>
import Namespace from "@lopatnov/namespace";
var Namespace = require("@lopatnov/namespace");
const ns = new Namespace(); // <-- create namespace variable
ns.namespace("a.b.c.d"); // <-- create inner namespaces
ns.namespace("a.b.c.e"); // <-- Function namespace(path: NamespacePath): Namespace
ns.namespace("a.b.f.g"); // <--
ns.namespace("a.i.h.k"); // <--
ns.namespace("a.i.h.l"); // <--
ns.namespace("a.m.n.o"); // <--
// Access to inner namespaces
const anyNS: any = ns; // <-- to avoid type casting
console.log(anyNS.a.b.f.g instanceof Namespace); // true
console.log((ns as any).a.b.c.d instanceof Namespace); // true
console.log((ns as any).a.b.c.e instanceof Namespace); // true
// Function exists(path: NamespacePath): boolean
console.log(ns.exists('a.b.c.d')); // true
console.log(ns.exists('a.b.c.e')); // true
console.log(ns.exists('a.b.f.g')); // true
console.log(ns.exists('a.i.h.k')); // true
console.log(ns.exists('a.i.h.l')); // true
console.log(ns.exists('a.m.n.o')); // true
var dynamicNamespace: any = Namespace; // <-- escape current TypeScript restrictions with any Type
var a = dynamicNamespace('Pacific.Ocean'); // <-- call as function
console.log(a.Pacific.Ocean instanceof Namespace); // true
var n: any = new Namespace("Hello.World");
console.log(n.Hello.World instanceof Namespace); // true
var eeny: any = new Namespace('meeny.miny.moe[Catch][a][tiger][by][the][toe]');
console.log(eeny.meeny.miny.moe.Catch.a.tiger.by.the.toe instanceof Namespace); // true
var kitchenRadar = new Namespace();
kitchenRadar.namespace('big.fruits');
kitchenRadar.namespace('big.eggs');
kitchenRadar.namespace('small.dishes');
kitchenRadar.namespace('small.cookies');
var fruits = kitchenRadar.goto('big.fruits'); // <-- goto(path: NamespacePath): any
var eggs = kitchenRadar.goto('big.eggs');
var dishes = kitchenRadar.goto('small.dishes');
var cookies = kitchenRadar.goto('small.cookies');
console.log(fruits === (kitchenRadar as any).big.fruits); // true
console.log(eggs === (kitchenRadar as any).big.eggs); // true
console.log(dishes === (kitchenRadar as any).small.dishes); // true
console.log(cookies === (kitchenRadar as any).small.cookies); // true
var persons: any = {};
var extension = new Namespace('with.small.kitty');
extension.applyTo(persons, 'Julia'); // Function applyTo(context: any, name: string): void
extension.applyTo(persons, 'Kathy');
extension.applyTo(persons, 'Liza');
console.log(persons.Julia.with.small.kitty instanceof Namespace); // true
console.log(persons.Kathy.with.small.kitty instanceof Namespace); // true
console.log(persons.Liza.with.small.kitty instanceof Namespace); // true
See, how it's working: https://runkit.com/lopatnov/namespace
Test it with a runkit: https://npm.runkit.com/@lopatnov/namespace
License Apache-2.0
Copyright 2020–2021 Oleksandr Lopatnov
FAQs
Dynamic namespace creation
The npm package @lopatnov/namespace receives a total of 0 weekly downloads. As such, @lopatnov/namespace popularity was classified as not popular.
We found that @lopatnov/namespace demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.