New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cpmech/basic

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cpmech/basic - npm Package Compare versions

Comparing version 3.8.0 to 3.9.0

dist/esm/fileTypeAndExt.d.ts

2

dist/cjs/index.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const filled=e=>""!==e&&"null"!==e,allFilled=(e,t)=>{let o;o=t?Object.keys(e).filter(e=>!t.includes(e)):Object.keys(e);for(const t of o)if(!filled(e[t]))return!1;return!0},camelize=(e,t=!1,o="_")=>t?e.split(o).map(e=>e.toLowerCase().replace(/./,e=>e.toUpperCase())).join(""):e.split(o).map((e,t)=>t>0?e.toLowerCase().replace(/./,e=>e.toUpperCase()):e.toLowerCase()).join(""),cloneSimple=e=>{const t={};for(const o of Object.keys(e)){const r=e[o];Array.isArray(r)?t[o]=r.slice(0):t[o]="object"==typeof r?cloneSimple(r):r}return t},copySimple=(e,t)=>{const o=Object.keys(e);for(const r of o){const o=t[r];Array.isArray(o)?e[r]=o.slice(0):"object"==typeof o?copySimple(e[r],o):e[r]=o}},email2key=e=>e.toLowerCase().replace(/[@\.]/g,"_"),formatCPF=e=>{const t=e.replace(/[\D\s._-]+/g,"");let o=4;const r=[];for(let e=0,s=t.length;e<s;e+=o)o=e<9?3:2,r.push(t.substr(e,o));return r.length>=4?r.slice(0,3).join(".")+"-"+r[3]:r.join(".")},getObjectKeys=(e,t=!0)=>{const o=[];for(const r of Object.keys(e)){const s=e[r];o.push(r),"object"!=typeof s||Array.isArray(s)||(t&&o.push("{"),getObjectKeys(s,t).forEach(e=>o.push(e)),t&&o.push("}"))}return o},hasProp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);class Locales{constructor(e,t="en",o="us"){this.getLocale=()=>this.locale,this.setLocale=e=>this.locale=e,this.getCountry=()=>this.country,this.setCountry=e=>this.country=e,this.getIndexDay=()=>"us"===this.country?1:0,this.getIndexMonth=()=>"us"===this.country?0:1,this.getFirstFieldMax=()=>"us"===this.country?12:31,this.getSecondFieldMax=()=>"us"===this.country?31:12,this.getDateFormat=()=>"us"===this.country?"MM/DD/YYYY":"DD/MM/YYYY",this.translate=(e,t="")=>{if(!hasProp(this.resources,this.locale))return`INTERNAL_ERROR: cannot find locale ${this.locale} in resources object`;const o=this.resources[this.locale];if(!e)return"INTERNAL_ERROR: path variable must not be empty";const r=e.split(".").reduce((e,t)=>hasProp(e,t)?e[t]:"",o);return r||(t||`INTERNAL_ERROR: cannot find message with path = ${e}`)},this.resources=e,this.locale=t,this.country=o}}const makeGetField=(e,t)=>o=>{if(!Object.prototype.hasOwnProperty.call(e,o))throw new Error(`cannot find ${o}`);const r=e[o];if(typeof r!==t)throw new Error(`type of ${o} is incorrect`);return r},makeSetField=(e,t,o)=>(r,s)=>{if(!Object.prototype.hasOwnProperty.call(e,r))throw new Error(`cannot find ${r}`);const l=e[r];if(typeof l!==o)throw new Error(`type of ${r} is incorrect`);l!==s&&(e[r]=s,t())},maybeCopySimple=(e,t)=>{for(const o of Object.keys(e))if(hasProp(t,o)){const r=t[o];null!=r&&(Array.isArray(r)?e[o]=r.slice(0):"object"==typeof r?maybeCopySimple(e[o],r):e[o]=r)}},numOnly=e=>e.replace(/[\D\s\._\-]+/g,""),sleep=e=>new Promise(t=>setTimeout(t,e)),shallowCompareArrays=(e,t)=>{if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0};exports.Locales=Locales,exports.allFilled=allFilled,exports.camelize=camelize,exports.cloneSimple=cloneSimple,exports.copySimple=copySimple,exports.email2key=email2key,exports.filled=filled,exports.formatCPF=formatCPF,exports.getObjectKeys=getObjectKeys,exports.hasProp=hasProp,exports.makeGetField=makeGetField,exports.makeSetField=makeSetField,exports.maybeCopySimple=maybeCopySimple,exports.numOnly=numOnly,exports.shallowCompareArrays=shallowCompareArrays,exports.sleep=sleep;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const filled=e=>""!==e&&"null"!==e,allFilled=(e,t)=>{let r;r=t?Object.keys(e).filter(e=>!t.includes(e)):Object.keys(e);for(const t of r)if(!filled(e[t]))return!1;return!0},camelize=(e,t=!1,r="_")=>t?e.split(r).map(e=>e.toLowerCase().replace(/./,e=>e.toUpperCase())).join(""):e.split(r).map((e,t)=>t>0?e.toLowerCase().replace(/./,e=>e.toUpperCase()):e.toLowerCase()).join(""),cloneSimple=e=>{const t={};for(const r of Object.keys(e)){const o=e[r];Array.isArray(o)?t[r]=o.slice(0):t[r]="object"==typeof o?cloneSimple(o):o}return t},copySimple=(e,t)=>{const r=Object.keys(e);for(const o of r){const r=t[o];Array.isArray(r)?e[o]=r.slice(0):"object"==typeof r?copySimple(e[o],r):e[o]=r}},email2key=e=>e.toLowerCase().replace(/[@\.]/g,"_"),ext2type=e=>{switch(e){case"jpeg":case"jpg":return"image/jpeg";case"png":return"image/png";case"pdf":return"application/pdf"}throw new Error(`cannot handle file extension = ${e} at this time`)},type2ext=e=>{switch(e){case"image/jpeg":return"jpeg";case"image/png":return"png";case"application/pdf":return"pdf"}throw new Error(`cannot handle content-type = ${e} at this time`)},formatCPF=e=>{const t=e.replace(/[\D\s._-]+/g,"");let r=4;const o=[];for(let e=0,s=t.length;e<s;e+=r)r=e<9?3:2,o.push(t.substr(e,r));return o.length>=4?o.slice(0,3).join(".")+"-"+o[3]:o.join(".")},getObjectKeys=(e,t=!0)=>{const r=[];for(const o of Object.keys(e)){const s=e[o];r.push(o),"object"!=typeof s||Array.isArray(s)||(t&&r.push("{"),getObjectKeys(s,t).forEach(e=>r.push(e)),t&&r.push("}"))}return r},hasProp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);class Locales{constructor(e,t="en",r="us"){this.getLocale=()=>this.locale,this.setLocale=e=>this.locale=e,this.getCountry=()=>this.country,this.setCountry=e=>this.country=e,this.getIndexDay=()=>"us"===this.country?1:0,this.getIndexMonth=()=>"us"===this.country?0:1,this.getFirstFieldMax=()=>"us"===this.country?12:31,this.getSecondFieldMax=()=>"us"===this.country?31:12,this.getDateFormat=()=>"us"===this.country?"MM/DD/YYYY":"DD/MM/YYYY",this.translate=(e,t="")=>{if(!hasProp(this.resources,this.locale))return`INTERNAL_ERROR: cannot find locale ${this.locale} in resources object`;const r=this.resources[this.locale];if(!e)return"INTERNAL_ERROR: path variable must not be empty";const o=e.split(".").reduce((e,t)=>hasProp(e,t)?e[t]:"",r);return o||(t||`INTERNAL_ERROR: cannot find message with path = ${e}`)},this.resources=e,this.locale=t,this.country=r}}const makeGetField=(e,t)=>r=>{if(!Object.prototype.hasOwnProperty.call(e,r))throw new Error(`cannot find ${r}`);const o=e[r];if(typeof o!==t)throw new Error(`type of ${r} is incorrect`);return o},makeSetField=(e,t,r)=>(o,s)=>{if(!Object.prototype.hasOwnProperty.call(e,o))throw new Error(`cannot find ${o}`);const l=e[o];if(typeof l!==r)throw new Error(`type of ${o} is incorrect`);l!==s&&(e[o]=s,t())},maybeCopySimple=(e,t)=>{for(const r of Object.keys(e))if(hasProp(t,r)){const o=t[r];null!=o&&(Array.isArray(o)?e[r]=o.slice(0):"object"==typeof o?maybeCopySimple(e[r],o):e[r]=o)}},numOnly=e=>e.replace(/[\D\s\._\-]+/g,""),sleep=e=>new Promise(t=>setTimeout(t,e)),shallowCompareArrays=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0};exports.Locales=Locales,exports.allFilled=allFilled,exports.camelize=camelize,exports.cloneSimple=cloneSimple,exports.copySimple=copySimple,exports.email2key=email2key,exports.ext2type=ext2type,exports.filled=filled,exports.formatCPF=formatCPF,exports.getObjectKeys=getObjectKeys,exports.hasProp=hasProp,exports.makeGetField=makeGetField,exports.makeSetField=makeSetField,exports.maybeCopySimple=maybeCopySimple,exports.numOnly=numOnly,exports.shallowCompareArrays=shallowCompareArrays,exports.sleep=sleep,exports.type2ext=type2ext;

@@ -6,2 +6,3 @@ export * from './allFilled';

export * from './email2key';
export * from './fileTypeAndExt';
export * from './filled';

@@ -8,0 +9,0 @@ export * from './formatCPF';

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

const t=t=>""!==t&&"null"!==t,e=(e,r)=>{let o;o=r?Object.keys(e).filter(t=>!r.includes(t)):Object.keys(e);for(const r of o)if(!t(e[r]))return!1;return!0},r=(t,e=!1,r="_")=>e?t.split(r).map(t=>t.toLowerCase().replace(/./,t=>t.toUpperCase())).join(""):t.split(r).map((t,e)=>e>0?t.toLowerCase().replace(/./,t=>t.toUpperCase()):t.toLowerCase()).join(""),o=t=>{const e={};for(const r of Object.keys(t)){const s=t[r];Array.isArray(s)?e[r]=s.slice(0):e[r]="object"==typeof s?o(s):s}return e},s=(t,e)=>{const r=Object.keys(t);for(const o of r){const r=e[o];Array.isArray(r)?t[o]=r.slice(0):"object"==typeof r?s(t[o],r):t[o]=r}},n=t=>t.toLowerCase().replace(/[@\.]/g,"_"),c=t=>{const e=t.replace(/[\D\s._-]+/g,"");let r=4;const o=[];for(let t=0,s=e.length;t<s;t+=r)r=t<9?3:2,o.push(e.substr(t,r));return o.length>=4?o.slice(0,3).join(".")+"-"+o[3]:o.join(".")},i=(t,e=!0)=>{const r=[];for(const o of Object.keys(t)){const s=t[o];r.push(o),"object"!=typeof s||Array.isArray(s)||(e&&r.push("{"),i(s,e).forEach(t=>r.push(t)),e&&r.push("}"))}return r},a=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class l{constructor(t,e="en",r="us"){this.getLocale=()=>this.locale,this.setLocale=t=>this.locale=t,this.getCountry=()=>this.country,this.setCountry=t=>this.country=t,this.getIndexDay=()=>"us"===this.country?1:0,this.getIndexMonth=()=>"us"===this.country?0:1,this.getFirstFieldMax=()=>"us"===this.country?12:31,this.getSecondFieldMax=()=>"us"===this.country?31:12,this.getDateFormat=()=>"us"===this.country?"MM/DD/YYYY":"DD/MM/YYYY",this.translate=(t,e="")=>{if(!a(this.resources,this.locale))return`INTERNAL_ERROR: cannot find locale ${this.locale} in resources object`;const r=this.resources[this.locale];if(!t)return"INTERNAL_ERROR: path variable must not be empty";const o=t.split(".").reduce((t,e)=>a(t,e)?t[e]:"",r);return o||(e||`INTERNAL_ERROR: cannot find message with path = ${t}`)},this.resources=t,this.locale=e,this.country=r}}const h=(t,e)=>r=>{if(!Object.prototype.hasOwnProperty.call(t,r))throw new Error(`cannot find ${r}`);const o=t[r];if(typeof o!==e)throw new Error(`type of ${r} is incorrect`);return o},u=(t,e,r)=>(o,s)=>{if(!Object.prototype.hasOwnProperty.call(t,o))throw new Error(`cannot find ${o}`);const n=t[o];if(typeof n!==r)throw new Error(`type of ${o} is incorrect`);n!==s&&(t[o]=s,e())},p=(t,e)=>{for(const r of Object.keys(t))if(a(e,r)){const o=e[r];null!=o&&(Array.isArray(o)?t[r]=o.slice(0):"object"==typeof o?p(t[r],o):t[r]=o)}},y=t=>t.replace(/[\D\s\._\-]+/g,""),f=t=>new Promise(e=>setTimeout(e,t)),j=(t,e)=>{if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0};export{l as Locales,e as allFilled,r as camelize,o as cloneSimple,s as copySimple,n as email2key,t as filled,c as formatCPF,i as getObjectKeys,a as hasProp,h as makeGetField,u as makeSetField,p as maybeCopySimple,y as numOnly,j as shallowCompareArrays,f as sleep};
const t=t=>""!==t&&"null"!==t,e=(e,r)=>{let o;o=r?Object.keys(e).filter(t=>!r.includes(t)):Object.keys(e);for(const r of o)if(!t(e[r]))return!1;return!0},r=(t,e=!1,r="_")=>e?t.split(r).map(t=>t.toLowerCase().replace(/./,t=>t.toUpperCase())).join(""):t.split(r).map((t,e)=>e>0?t.toLowerCase().replace(/./,t=>t.toUpperCase()):t.toLowerCase()).join(""),o=t=>{const e={};for(const r of Object.keys(t)){const s=t[r];Array.isArray(s)?e[r]=s.slice(0):e[r]="object"==typeof s?o(s):s}return e},s=(t,e)=>{const r=Object.keys(t);for(const o of r){const r=e[o];Array.isArray(r)?t[o]=r.slice(0):"object"==typeof r?s(t[o],r):t[o]=r}},n=t=>t.toLowerCase().replace(/[@\.]/g,"_"),c=t=>{switch(t){case"jpeg":case"jpg":return"image/jpeg";case"png":return"image/png";case"pdf":return"application/pdf"}throw new Error(`cannot handle file extension = ${t} at this time`)},i=t=>{switch(t){case"image/jpeg":return"jpeg";case"image/png":return"png";case"application/pdf":return"pdf"}throw new Error(`cannot handle content-type = ${t} at this time`)},a=t=>{const e=t.replace(/[\D\s._-]+/g,"");let r=4;const o=[];for(let t=0,s=e.length;t<s;t+=r)r=t<9?3:2,o.push(e.substr(t,r));return o.length>=4?o.slice(0,3).join(".")+"-"+o[3]:o.join(".")},l=(t,e=!0)=>{const r=[];for(const o of Object.keys(t)){const s=t[o];r.push(o),"object"!=typeof s||Array.isArray(s)||(e&&r.push("{"),l(s,e).forEach(t=>r.push(t)),e&&r.push("}"))}return r},p=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class h{constructor(t,e="en",r="us"){this.getLocale=()=>this.locale,this.setLocale=t=>this.locale=t,this.getCountry=()=>this.country,this.setCountry=t=>this.country=t,this.getIndexDay=()=>"us"===this.country?1:0,this.getIndexMonth=()=>"us"===this.country?0:1,this.getFirstFieldMax=()=>"us"===this.country?12:31,this.getSecondFieldMax=()=>"us"===this.country?31:12,this.getDateFormat=()=>"us"===this.country?"MM/DD/YYYY":"DD/MM/YYYY",this.translate=(t,e="")=>{if(!p(this.resources,this.locale))return`INTERNAL_ERROR: cannot find locale ${this.locale} in resources object`;const r=this.resources[this.locale];if(!t)return"INTERNAL_ERROR: path variable must not be empty";const o=t.split(".").reduce((t,e)=>p(t,e)?t[e]:"",r);return o||(e||`INTERNAL_ERROR: cannot find message with path = ${t}`)},this.resources=t,this.locale=e,this.country=r}}const u=(t,e)=>r=>{if(!Object.prototype.hasOwnProperty.call(t,r))throw new Error(`cannot find ${r}`);const o=t[r];if(typeof o!==e)throw new Error(`type of ${r} is incorrect`);return o},f=(t,e,r)=>(o,s)=>{if(!Object.prototype.hasOwnProperty.call(t,o))throw new Error(`cannot find ${o}`);const n=t[o];if(typeof n!==r)throw new Error(`type of ${o} is incorrect`);n!==s&&(t[o]=s,e())},y=(t,e)=>{for(const r of Object.keys(t))if(p(e,r)){const o=e[r];null!=o&&(Array.isArray(o)?t[r]=o.slice(0):"object"==typeof o?y(t[r],o):t[r]=o)}},g=t=>t.replace(/[\D\s\._\-]+/g,""),j=t=>new Promise(e=>setTimeout(e,t)),w=(t,e)=>{if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0};export{h as Locales,e as allFilled,r as camelize,o as cloneSimple,s as copySimple,n as email2key,c as ext2type,t as filled,a as formatCPF,l as getObjectKeys,p as hasProp,u as makeGetField,f as makeSetField,y as maybeCopySimple,g as numOnly,w as shallowCompareArrays,j as sleep,i as type2ext};
{
"name": "@cpmech/basic",
"version": "3.8.0",
"version": "3.9.0",
"license": "MIT",

@@ -39,3 +39,3 @@ "author": {

"ts-jest": "^24.2.0",
"ts-node": "^8.5.2",
"ts-node": "^8.5.4",
"tslint": "^5.20.1",

@@ -45,3 +45,3 @@ "tslint-config-prettier": "^1.18.0",

},
"gitHead": "8b91aeb5451a8af28726ee6efd6cda18d5ec0111"
"gitHead": "5d1ad851ae7ed38eaec7780532fc919494b83106"
}
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