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

@pro-functional/objects

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pro-functional/objects - npm Package Compare versions

Comparing version
0.1.3
to
0.1.5
+2
dist/cjs/enum.js
"use strict";var o=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(r,e)=>{for(var n in e)o(r,n,{get:e[n],enumerable:!0})},v=(r,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of a(e))!c.call(r,t)&&t!==n&&o(r,t,{get:()=>e[t],enumerable:!(s=g(e,t))||s.enumerable});return r};var i=r=>v(o({},"__esModule",{value:!0}),r);var u={};l(u,{makeEnumResolver:()=>p});module.exports=i(u);const p=(r,e)=>n=>new Map(Object.values(r).map(t=>[t.toString(),t])).get(n)||e;
//# sourceMappingURL=enum.js.map
{
"version": 3,
"sources": ["../../src/enum.ts"],
"sourcesContent": ["export const makeEnumResolver =\n <T extends string>(record: Record<string, T>, fallback: T) =>\n (value: string) => {\n const resolver = new Map(\n Object.values(record).map((item) => [item.toString(), item])\n )\n\n return resolver.get(value) || fallback\n }\n"],
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EACT,CAAmBE,EAA2BC,IAC7CC,GACoB,IAAI,IACjB,OAAO,OAAOF,CAAM,EAAE,IAAKG,GAAS,CAACA,EAAK,SAAS,EAAGA,CAAI,CAAC,CAC/D,EAEgB,IAAID,CAAK,GAAKD",
"names": ["enum_exports", "__export", "makeEnumResolver", "__toCommonJS", "record", "fallback", "value", "item"]
}
"use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},p=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of h(t))!b.call(e,c)&&c!==n&&s(e,c,{get:()=>t[c],enumerable:!(o=a(t,c))||o.enumerable});return e};var u=e=>p(s({},"__esModule",{value:!0}),e);var K={};k(K,{checkObject:()=>m,isObject:()=>i,isObjectWithProps:()=>T,matchesEnum:()=>j,matchesList:()=>y,matchesNumber:()=>x,matchesOneOf:()=>d,matchesString:()=>r});module.exports=u(K);const i=e=>typeof e=="object"&&!!e,T=(e,...t)=>i(e)&&t.every(n=>n in e),m=e=>{const t=(o,c)=>n(c(e[o]),e),n=(o,c)=>({isMatch:()=>o,object:c,withProp:t});return n(!!e,e)},r=e=>typeof e=="string",x=e=>typeof e=="number",d=(e,t)=>r(e)&&t.some(n=>e===n),j=e=>t=>r(t)&&Object.keys(e).includes(t),y=e=>t=>Array.isArray(t)&&t.every(e);
//# sourceMappingURL=objects.js.map
{
"version": 3,
"sources": ["../../src/objects.ts"],
"sourcesContent": ["export const isObject = (value?: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && !!value\n\nexport const isObjectWithProps = <K extends string>(\n value?: unknown,\n ...props: K[]\n): value is { [k in K]: unknown } =>\n isObject(value) && props.every((prop) => prop in value)\n\ntype MatchFunc<T> = (param: T) => boolean\n\ninterface MatchWithPropFunc<T extends object> {\n <K extends keyof T>(\n key: K,\n match: MatchFunc<T[K]>\n ): CheckObjectIntermediate<T>\n}\n\ninterface CheckObjectIntermediate<T extends object> {\n isMatch: () => boolean\n object: T\n withProp: MatchWithPropFunc<T>\n}\n\nexport const checkObject = <T extends object>(\n value: T\n): CheckObjectIntermediate<T> => {\n const withProp = <K extends keyof T>(key: K, matchFunc: MatchFunc<T[K]>) =>\n next(matchFunc(value[key]), value)\n\n const next = (result: boolean, object: T): CheckObjectIntermediate<T> => ({\n isMatch: () => result,\n object,\n withProp,\n })\n\n return next(!!value, value)\n}\n\nexport const matchesString = (value: unknown): value is string =>\n typeof value === 'string'\n\nexport const matchesNumber = (value: unknown): value is number =>\n typeof value === 'number'\n\nexport const matchesOneOf = <K extends string>(\n value: unknown,\n sample: K[]\n): value is K => matchesString(value) && sample.some((key) => value === key)\n\nexport const matchesEnum =\n (enumerated: Record<string, string>) => (value: unknown) =>\n matchesString(value) && Object.keys(enumerated).includes(value)\n\nexport const matchesList =\n <T>(matchFunc: MatchFunc<T>) =>\n (value: unknown) =>\n Array.isArray(value) && value.every(matchFunc)\n"],
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,aAAAC,EAAA,sBAAAC,EAAA,gBAAAC,EAAA,gBAAAC,EAAA,kBAAAC,EAAA,iBAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAV,GAAO,MAAMG,EAAYQ,GACrB,OAAOA,GAAU,UAAY,CAAC,CAACA,EAEtBP,EAAoB,CAC7BO,KACGC,IAEHT,EAASQ,CAAK,GAAKC,EAAM,MAAOC,GAASA,KAAQF,CAAK,EAiB7CT,EACTS,GAC6B,CAC7B,MAAMG,EAAW,CAAoBC,EAAQC,IACzCC,EAAKD,EAAUL,EAAMI,CAAG,CAAC,EAAGJ,CAAK,EAE/BM,EAAO,CAACC,EAAiBC,KAA2C,CACtE,QAAS,IAAMD,EACf,OAAAC,EACA,SAAAL,CACJ,GAEA,OAAOG,EAAK,CAAC,CAACN,EAAOA,CAAK,CAC9B,EAEaF,EAAiBE,GAC1B,OAAOA,GAAU,SAERJ,EAAiBI,GAC1B,OAAOA,GAAU,SAERH,EAAe,CACxBG,EACAS,IACaX,EAAcE,CAAK,GAAKS,EAAO,KAAML,GAAQJ,IAAUI,CAAG,EAE9DV,EACRgB,GAAwCV,GACrCF,EAAcE,CAAK,GAAK,OAAO,KAAKU,CAAU,EAAE,SAASV,CAAK,EAEzDL,EACLU,GACHL,GACG,MAAM,QAAQA,CAAK,GAAKA,EAAM,MAAMK,CAAS",
"names": ["objects_exports", "__export", "checkObject", "isObject", "isObjectWithProps", "matchesEnum", "matchesList", "matchesNumber", "matchesOneOf", "matchesString", "__toCommonJS", "value", "props", "prop", "withProp", "key", "matchFunc", "next", "result", "object", "sample", "enumerated"]
}
const o=(r,t)=>n=>new Map(Object.values(r).map(e=>[e.toString(),e])).get(n)||t;export{o as makeEnumResolver};
//# sourceMappingURL=enum.js.map
{
"version": 3,
"sources": ["../../src/enum.ts"],
"sourcesContent": ["export const makeEnumResolver =\n <T extends string>(record: Record<string, T>, fallback: T) =>\n (value: string) => {\n const resolver = new Map(\n Object.values(record).map((item) => [item.toString(), item])\n )\n\n return resolver.get(value) || fallback\n }\n"],
"mappings": "AAAO,MAAMA,EACT,CAAmBC,EAA2BC,IAC7CC,GACoB,IAAI,IACjB,OAAO,OAAOF,CAAM,EAAE,IAAKG,GAAS,CAACA,EAAK,SAAS,EAAGA,CAAI,CAAC,CAC/D,EAEgB,IAAID,CAAK,GAAKD",
"names": ["makeEnumResolver", "record", "fallback", "value", "item"]
}
const r=e=>typeof e=="object"&&!!e,i=(e,...t)=>r(e)&&t.every(n=>n in e),a=e=>{const t=(c,o)=>n(o(e[c]),e),n=(c,o)=>({isMatch:()=>c,object:o,withProp:t});return n(!!e,e)},s=e=>typeof e=="string",h=e=>typeof e=="number",b=(e,t)=>s(e)&&t.some(n=>e===n),k=e=>t=>s(t)&&Object.keys(e).includes(t),p=e=>t=>Array.isArray(t)&&t.every(e);export{a as checkObject,r as isObject,i as isObjectWithProps,k as matchesEnum,p as matchesList,h as matchesNumber,b as matchesOneOf,s as matchesString};
//# sourceMappingURL=objects.js.map
{
"version": 3,
"sources": ["../../src/objects.ts"],
"sourcesContent": ["export const isObject = (value?: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && !!value\n\nexport const isObjectWithProps = <K extends string>(\n value?: unknown,\n ...props: K[]\n): value is { [k in K]: unknown } =>\n isObject(value) && props.every((prop) => prop in value)\n\ntype MatchFunc<T> = (param: T) => boolean\n\ninterface MatchWithPropFunc<T extends object> {\n <K extends keyof T>(\n key: K,\n match: MatchFunc<T[K]>\n ): CheckObjectIntermediate<T>\n}\n\ninterface CheckObjectIntermediate<T extends object> {\n isMatch: () => boolean\n object: T\n withProp: MatchWithPropFunc<T>\n}\n\nexport const checkObject = <T extends object>(\n value: T\n): CheckObjectIntermediate<T> => {\n const withProp = <K extends keyof T>(key: K, matchFunc: MatchFunc<T[K]>) =>\n next(matchFunc(value[key]), value)\n\n const next = (result: boolean, object: T): CheckObjectIntermediate<T> => ({\n isMatch: () => result,\n object,\n withProp,\n })\n\n return next(!!value, value)\n}\n\nexport const matchesString = (value: unknown): value is string =>\n typeof value === 'string'\n\nexport const matchesNumber = (value: unknown): value is number =>\n typeof value === 'number'\n\nexport const matchesOneOf = <K extends string>(\n value: unknown,\n sample: K[]\n): value is K => matchesString(value) && sample.some((key) => value === key)\n\nexport const matchesEnum =\n (enumerated: Record<string, string>) => (value: unknown) =>\n matchesString(value) && Object.keys(enumerated).includes(value)\n\nexport const matchesList =\n <T>(matchFunc: MatchFunc<T>) =>\n (value: unknown) =>\n Array.isArray(value) && value.every(matchFunc)\n"],
"mappings": "AAAO,MAAMA,EAAYC,GACrB,OAAOA,GAAU,UAAY,CAAC,CAACA,EAEtBC,EAAoB,CAC7BD,KACGE,IAEHH,EAASC,CAAK,GAAKE,EAAM,MAAOC,GAASA,KAAQH,CAAK,EAiB7CI,EACTJ,GAC6B,CAC7B,MAAMK,EAAW,CAAoBC,EAAQC,IACzCC,EAAKD,EAAUP,EAAMM,CAAG,CAAC,EAAGN,CAAK,EAE/BQ,EAAO,CAACC,EAAiBC,KAA2C,CACtE,QAAS,IAAMD,EACf,OAAAC,EACA,SAAAL,CACJ,GAEA,OAAOG,EAAK,CAAC,CAACR,EAAOA,CAAK,CAC9B,EAEaW,EAAiBX,GAC1B,OAAOA,GAAU,SAERY,EAAiBZ,GAC1B,OAAOA,GAAU,SAERa,EAAe,CACxBb,EACAc,IACaH,EAAcX,CAAK,GAAKc,EAAO,KAAMR,GAAQN,IAAUM,CAAG,EAE9DS,EACRC,GAAwChB,GACrCW,EAAcX,CAAK,GAAK,OAAO,KAAKgB,CAAU,EAAE,SAAShB,CAAK,EAEzDiB,EACLV,GACHP,GACG,MAAM,QAAQA,CAAK,GAAKA,EAAM,MAAMO,CAAS",
"names": ["isObject", "value", "isObjectWithProps", "props", "prop", "checkObject", "withProp", "key", "matchFunc", "next", "result", "object", "matchesString", "matchesNumber", "matchesOneOf", "sample", "matchesEnum", "enumerated", "matchesList"]
}
export declare const makeEnumResolver: <T extends string>(record: Record<string, T>, fallback: T) => (value: string) => T;
The MIT License (MIT)
Copyright 2025 Harish Prakash
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Objects
## Installation
```sh
yarn add --exact @pro-functional/objects
```
## Tools
**isObject** A type checker to evaluate the given value as an
`NonNullable<object>`
```ts
isObject(null)
// false
isObject(undefined)
// false
isObject(5)
// false
isObject('random value')
// false
isObject({})
// true
```
**isObjectWithProps** A type checker that verifies the provided value to be an
object with the provided property keys
```ts
isObjectWithProps(null, 'name', 'id')
// false
isObjectWithProps(undefined, 'name', 'id')
// false
isObjectWithProps(5, 'name', 'id')
// false
isObjectWithProps('random value', 'name', 'id')
// false
isObjectWithProps({}, 'name', 'id')
// false
isObjectWithProps({ name: 'bob' }, 'name', 'id')
// false
isObjectWithProps({ name: 'bob', id: '007', uid: 'ga98as7fuhk' }, 'name', 'id')
// true
interface User {
name: string
id: string
}
const maybeUser = { name: 'bob', id: '007', uid: 'ga98as7fuhk' }
const user: User | null = isObjectWithProps(maybeUser, 'name', 'id')
? maybeUser
: null
// ✅ assignment is type-correct
```
**makeEnumResolver** Create a resolver for an Enum allowing you to map a text
back to the enum. The fallback allows a guaranteed response.
```ts
enum Colors {
Green = 'green',
Blue = 'blue',
Invalid = 'invalid',
}
const resolveColor = makeEnumResolver(Colors, Colors.Invalid)
resolveColor('green')
// Colors.Green
resolveColor('blue')
// Colors.Blue
resolveColor('purple')
// Colors.Invalid
```
+1
-1

@@ -1,2 +0,2 @@

"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(n,o)=>{for(var t in o)s(n,t,{get:o[t],enumerable:!0})},w=(n,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of k(o))!p.call(n,e)&&e!==t&&s(n,e,{get:()=>o[e],enumerable:!(i=c(o,e))||i.enumerable});return n};var x=n=>w(s({},"__esModule",{value:!0}),n);var j={};u(j,{isObject:()=>r,isObjectWithProps:()=>b});module.exports=x(j);var r=n=>typeof n=="object"&&!!n,b=(n,...o)=>r(n)&&o.every(t=>t in n);
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(r,m)&&m!==p&&a(r,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return r},f=(r,o,p)=>(t(r,o,"default"),p&&t(p,o,"default"));var g=r=>t(a({},"__esModule",{value:!0}),r);var e={};module.exports=g(e);f(e,require("./enum"),module.exports);f(e,require("./objects"),module.exports);
//# sourceMappingURL=index.js.map
{
"version": 3,
"sources": ["../../src/index.ts", "../../src/objects.ts"],
"sourcesContent": ["export * from './objects'\n", "export const isObject = (value?: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && !!value\n\nexport const isObjectWithProps = <K extends string>(\n value?: unknown,\n ...props: K[]\n): value is { [k in K]: unknown } =>\n isObject(value) && props.every((prop) => prop in value)\n"],
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,sBAAAC,IAAA,eAAAC,EAAAJ,GCAO,IAAMK,EAAYC,GACrB,OAAOA,GAAU,UAAY,CAAC,CAACA,EAEtBC,EAAoB,CAC7BD,KACGE,IAEHH,EAASC,CAAK,GAAKE,EAAM,MAAOC,GAASA,KAAQH,CAAK",
"names": ["index_exports", "__export", "isObject", "isObjectWithProps", "__toCommonJS", "isObject", "value", "isObjectWithProps", "props", "prop"]
"sources": ["../../src/index.ts"],
"sourcesContent": ["export * from './enum'\nexport * from './objects'\n"],
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,kBAAd,gBACAE,EAAAF,EAAc,qBADd",
"names": ["index_exports", "__toCommonJS", "__reExport"]
}

@@ -1,2 +0,2 @@

var e=n=>typeof n=="object"&&!!n,s=(n,...o)=>e(n)&&o.every(t=>t in n);export{e as isObject,s as isObjectWithProps};
export*from"./enum";export*from"./objects";
//# sourceMappingURL=index.js.map
{
"version": 3,
"sources": ["../../src/objects.ts"],
"sourcesContent": ["export const isObject = (value?: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && !!value\n\nexport const isObjectWithProps = <K extends string>(\n value?: unknown,\n ...props: K[]\n): value is { [k in K]: unknown } =>\n isObject(value) && props.every((prop) => prop in value)\n"],
"mappings": "AAAO,IAAMA,EAAYC,GACrB,OAAOA,GAAU,UAAY,CAAC,CAACA,EAEtBC,EAAoB,CAC7BD,KACGE,IAEHH,EAASC,CAAK,GAAKE,EAAM,MAAOC,GAASA,KAAQH,CAAK",
"names": ["isObject", "value", "isObjectWithProps", "props", "prop"]
"sources": ["../../src/index.ts"],
"sourcesContent": ["export * from './enum'\nexport * from './objects'\n"],
"mappings": "AAAA,WAAc,SACd,WAAc",
"names": []
}

@@ -0,1 +1,2 @@

export * from './enum';
export * from './objects';
export declare const isObject: (value?: unknown) => value is Record<string, unknown>;
export declare const isObjectWithProps: <K extends string>(value?: unknown, ...props: K[]) => value is { [k in K]: unknown; };
type MatchFunc<T> = (param: T) => boolean;
interface MatchWithPropFunc<T extends object> {
<K extends keyof T>(key: K, match: MatchFunc<T[K]>): CheckObjectIntermediate<T>;
}
interface CheckObjectIntermediate<T extends object> {
isMatch: () => boolean;
object: T;
withProp: MatchWithPropFunc<T>;
}
export declare const checkObject: <T extends object>(value: T) => CheckObjectIntermediate<T>;
export declare const matchesString: (value: unknown) => value is string;
export declare const matchesNumber: (value: unknown) => value is number;
export declare const matchesOneOf: <K extends string>(value: unknown, sample: K[]) => value is K;
export declare const matchesEnum: (enumerated: Record<string, string>) => (value: unknown) => boolean;
export declare const matchesList: <T>(matchFunc: MatchFunc<T>) => (value: unknown) => boolean;
export {};
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@pro-functional/objects",
"version": "0.1.3",
"version": "0.1.5",
"author": {

@@ -11,7 +11,7 @@ "name": "Harish Prakash",

"scripts": {
"build:cjs": "esbuild src/index.ts --bundle --outdir=dist/cjs --sourcemap --minify --tsconfig=tsconfig.build.json --format=cjs",
"build:esm": "esbuild src/index.ts --bundle --outdir=dist/esm --sourcemap --minify --tsconfig=tsconfig.build.json --format=esm",
"build:base": "esbuild src/**/*.ts --sourcemap --minify --tsconfig=tsconfig.build.json",
"build:cjs": "yarn build:base --outdir=dist/cjs --format=cjs",
"build:esm": "yarn build:base --outdir=dist/esm --format=esm",
"build:types": "tsc --project tsconfig.build.json",
"build": "yarn build:cjs && yarn build:esm && yarn build:types",
"build!": "yarn clean && yarn build",
"clean": "rimraf ./dist"

@@ -55,4 +55,3 @@ },

"typescript": "5.7.3"
},
"gitHead": "e0596b0220e0d5cbe366c5118ac1f58267e78473"
}
}
Copyright 2025 Harish Prakash
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.