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

@intlify/message-resolver

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intlify/message-resolver - npm Package Compare versions

Comparing version 9.0.0-rc.2 to 9.0.0-rc.3

46

dist/message-resolver.cjs.js
/*!
* @intlify/message-resolver v9.0.0-rc.2
* @intlify/message-resolver v9.0.0-rc.3
* (c) 2021 kazuya kawaguchi

@@ -252,4 +252,48 @@ * Released under the MIT License.

}
/**
* Transform flat json in obj to normal json in obj
*/
function handleFlatJson(obj) {
// check obj
if (!isObject(obj)) {
return obj;
}
for (const key in obj) {
// check key
if (!obj.hasOwnProperty(key)) {
continue;
}
// handle for normal json
if (!key.includes("." /* DOT */)) {
// recursive process value if value is also a object
if (typeof obj[key] === 'object') {
handleFlatJson(obj[key]);
}
}
// handle for flat json, transform to normal json
else {
// go to the last object
const subKeys = key.split("." /* DOT */);
const lastIndex = subKeys.length - 1;
let currentObj = obj;
for (let i = 0; i < lastIndex; i++) {
if (!(subKeys[i] in currentObj)) {
currentObj[subKeys[i]] = {};
}
currentObj = currentObj[subKeys[i]];
}
// update last object value, delete old property
currentObj[subKeys[lastIndex]] = obj[key];
delete obj[key];
// recursive process value if value is also a object
if (typeof currentObj[subKeys[lastIndex]] === 'object') {
handleFlatJson(currentObj[subKeys[lastIndex]]);
}
}
}
return obj;
}
exports.handleFlatJson = handleFlatJson;
exports.parse = parse;
exports.resolveValue = resolveValue;
/*!
* @intlify/message-resolver v9.0.0-rc.2
* @intlify/message-resolver v9.0.0-rc.3
* (c) 2021 kazuya kawaguchi

@@ -252,4 +252,48 @@ * Released under the MIT License.

}
/**
* Transform flat json in obj to normal json in obj
*/
function handleFlatJson(obj) {
// check obj
if (!isObject(obj)) {
return obj;
}
for (const key in obj) {
// check key
if (!obj.hasOwnProperty(key)) {
continue;
}
// handle for normal json
if (!key.includes("." /* DOT */)) {
// recursive process value if value is also a object
if (typeof obj[key] === 'object') {
handleFlatJson(obj[key]);
}
}
// handle for flat json, transform to normal json
else {
// go to the last object
const subKeys = key.split("." /* DOT */);
const lastIndex = subKeys.length - 1;
let currentObj = obj;
for (let i = 0; i < lastIndex; i++) {
if (!(subKeys[i] in currentObj)) {
currentObj[subKeys[i]] = {};
}
currentObj = currentObj[subKeys[i]];
}
// update last object value, delete old property
currentObj[subKeys[lastIndex]] = obj[key];
delete obj[key];
// recursive process value if value is also a object
if (typeof currentObj[subKeys[lastIndex]] === 'object') {
handleFlatJson(currentObj[subKeys[lastIndex]]);
}
}
}
return obj;
}
exports.handleFlatJson = handleFlatJson;
exports.parse = parse;
exports.resolveValue = resolveValue;
/**
* Transform flat json in obj to normal json in obj
*/
export declare function handleFlatJson(obj: unknown): unknown;
/**
* Parse a string path into an array of segments

@@ -4,0 +9,0 @@ */

/*!
* @intlify/message-resolver v9.0.0-rc.2
* @intlify/message-resolver v9.0.0-rc.3
* (c) 2021 kazuya kawaguchi

@@ -249,3 +249,46 @@ * Released under the MIT License.

}
/**
* Transform flat json in obj to normal json in obj
*/
function handleFlatJson(obj) {
// check obj
if (!isObject(obj)) {
return obj;
}
for (const key in obj) {
// check key
if (!obj.hasOwnProperty(key)) {
continue;
}
// handle for normal json
if (!key.includes("." /* DOT */)) {
// recursive process value if value is also a object
if (typeof obj[key] === 'object') {
handleFlatJson(obj[key]);
}
}
// handle for flat json, transform to normal json
else {
// go to the last object
const subKeys = key.split("." /* DOT */);
const lastIndex = subKeys.length - 1;
let currentObj = obj;
for (let i = 0; i < lastIndex; i++) {
if (!(subKeys[i] in currentObj)) {
currentObj[subKeys[i]] = {};
}
currentObj = currentObj[subKeys[i]];
}
// update last object value, delete old property
currentObj[subKeys[lastIndex]] = obj[key];
delete obj[key];
// recursive process value if value is also a object
if (typeof currentObj[subKeys[lastIndex]] === 'object') {
handleFlatJson(currentObj[subKeys[lastIndex]]);
}
}
}
return obj;
}
export { parse, resolveValue };
export { handleFlatJson, parse, resolveValue };

2

package.json
{
"name": "@intlify/message-resolver",
"version": "9.0.0-rc.2",
"version": "9.0.0-rc.3",
"description": "@intlify/message-resolver",

@@ -5,0 +5,0 @@ "keywords": [

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