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

@agencebio/rosetta-cultures

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agencebio/rosetta-cultures - npm Package Compare versions

Comparing version 1.8.2 to 1.8.3

15

dist/cjs/index.js

@@ -90,6 +90,19 @@ "use strict";

if (precision === void 0) { precision = null; }
if (precision) {
var cleanedPrecision_1 = String(precision).padStart(3, '0');
var results = cpf_json_1.default.filter(function (_a) {
var cultures_pac = _a.cultures_pac;
return cultures_pac.some(function (culture) {
return culture.code === code && culture.precision === cleanedPrecision_1;
});
});
if (results.length) {
return results;
}
}
// otherwise, and in any case, we lookup results without precision
return cpf_json_1.default.filter(function (_a) {
var cultures_pac = _a.cultures_pac;
return cultures_pac.some(function (culture) {
return culture.code === code && culture.precision === (precision ? String(precision).padStart(3, '0') : '');
return culture.code === code && culture.precision === '';
});

@@ -96,0 +109,0 @@ });

@@ -82,5 +82,20 @@ /**

export function fromCodePacAll (code, precision = null) {
if (precision) {
const cleanedPrecision = String(precision).padStart(3, '0')
const results = cpf.filter(({ cultures_pac }) => {
return cultures_pac.some(culture => {
return culture.code === code && culture.precision === cleanedPrecision
})
})
if (results.length) {
return results
}
}
// otherwise, and in any case, we lookup results without precision
return cpf.filter(({ cultures_pac }) => {
return cultures_pac.some(culture => {
return culture.code === code && culture.precision === (precision ? String(precision).padStart(3, '0') : '')
return culture.code === code && culture.precision === ''
})

@@ -91,3 +106,2 @@ })

/**

@@ -94,0 +108,0 @@ * @param {String} code

@@ -90,2 +90,7 @@ import { describe, it } from 'node:test'

deepEqual(fromCodePacFirst('VRG', '002').code_cpf, "01.25.31") // Amandes
// inexisting precision falls back to regular code
deepEqual(fromCodePacFirst('BTH', '001'), fromCodePacFirst('BTH')) // Blé tendre d’hiver
// digit version = string version
deepEqual(fromCodePacFirst('VRG', 1), fromCodePacFirst('VRG', '001')) // Abricots

@@ -133,2 +138,7 @@ deepEqual(fromCodePacFirst('VRG', 2), fromCodePacFirst('VRG', '002')) // Amandes

deepEqual(
fromCodePacAll('VRG', '002').map(({ code_cpf }) => code_cpf),
['01.25.31']
)
deepEqual(
fromCodePacAll('VRG', '003').map(({ code_cpf }) => code_cpf),

@@ -135,0 +145,0 @@ ['01.24.10.1', '01.24.10.2']

2

package.json
{
"name": "@agencebio/rosetta-cultures",
"version": "1.8.2",
"version": "1.8.3",
"description": "Traduction des codes cultures de la CPF vers la PAC vers des nomenclatures d'organismes de certification, et vice-versa.",

@@ -5,0 +5,0 @@ "main": "index.js",

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