jsonasarray
Advanced tools
| export default function (scope) { | ||
| return { ...scope, ...Object.assign({}, ...Array.from(arguments).splice(1)) }; | ||
| } |
| export default function (scope) { | ||
| return Object.keys(scope).length; | ||
| } |
| import { count } from './index'; | ||
| export default function (scope, callback) { | ||
| const set = []; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| if (callback(value, key, scope) === true) { | ||
| set.push(true); | ||
| } | ||
| } | ||
| return set.length === count(scope); | ||
| } |
| import { noop } from '../code'; | ||
| export default function (scope, callback = noop) { | ||
| const set = {}; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| if (callback(value, key, scope) === true) { | ||
| set[key] = value; | ||
| } | ||
| } | ||
| return set; | ||
| } |
| import { noop } from '../code'; | ||
| export default function (scope, callback = noop) { | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| callback(value, key, scope); | ||
| } | ||
| } |
| export default function (scope, value) { | ||
| for (const key in scope) { | ||
| if (scope[key] === value) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } |
| // Count | ||
| export { default as count } from './count'; | ||
| // Loop | ||
| export { default as forEach } from './forEach'; | ||
| export { default as map } from './map'; | ||
| export { default as filter } from './filter'; | ||
| export { default as some } from './some'; | ||
| export { default as every } from './every'; | ||
| // Check | ||
| export { default as includes } from './includes'; | ||
| // Find | ||
| export { default as indexOf } from './indexOf'; | ||
| // Insert | ||
| export { default as unshift } from './unshift'; | ||
| export { default as push } from './push'; | ||
| // Delete | ||
| export { default as shift } from './shift'; | ||
| export { default as pop } from './pop'; | ||
| // Batch | ||
| export { default as slice } from './slice'; | ||
| export { default as splice } from './splice'; | ||
| // Connect | ||
| export { default as concat } from './concat'; | ||
| export { default as join } from './join'; | ||
| // Extension | ||
| export { default as keys } from './keys'; | ||
| export { default as values } from './values'; |
| export default function (scope, value) { | ||
| let index = -1; | ||
| for (const key in scope) { | ||
| index++; | ||
| if (scope[key] === value) { | ||
| return index; | ||
| } | ||
| } | ||
| return index; | ||
| } |
| export default function (scope, separator = ',', mode = 'value') { | ||
| const key = mode === 'value'; | ||
| let set = ''; | ||
| for (const item of Object.entries(scope)) { | ||
| set += `${separator}${item[+key]}`; | ||
| } | ||
| return set.substring(1); | ||
| } |
| export default function (scope) { | ||
| return Object.keys(scope); | ||
| } |
| import { noop } from '../code'; | ||
| export default function (scope, callback = noop) { | ||
| const set = {}; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| set[key] = callback(value, key, scope); | ||
| } | ||
| return set; | ||
| } |
| export default function (scope) { | ||
| let sign; | ||
| let last; | ||
| for (const key in scope) { | ||
| sign = key; | ||
| } | ||
| last = { [sign]: scope[sign] }; | ||
| delete scope[sign]; | ||
| return last; | ||
| } |
| import { count } from './index'; | ||
| export default function (scope, json) { | ||
| return Object.assign(scope, json), count(scope); | ||
| } |
| export default function (scope) { | ||
| let first; | ||
| for (const key in scope) { | ||
| first = { [key]: scope[key] }; | ||
| delete scope[key]; | ||
| break; | ||
| } | ||
| return first; | ||
| } |
| import { count } from './index'; | ||
| export default function (scope, start = 0, step = count(scope) - start) { | ||
| let index = -1; | ||
| let set = {}; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| index++; | ||
| if (index < start) { | ||
| continue; | ||
| } | ||
| if (index >= start + step) { | ||
| break; | ||
| } | ||
| set[key] = value; | ||
| } | ||
| return set; | ||
| } |
| import { noop } from '../code'; | ||
| export default function (scope, callback = noop) { | ||
| const set = []; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| if (callback(value, key, scope) === true) { | ||
| set.push(true); | ||
| } | ||
| } | ||
| return !!set.length; | ||
| } |
| import { count } from './index'; | ||
| export default function (scope, start = 0, step = count(scope) - start, json) { | ||
| const group = Object.entries(scope); | ||
| const lost = group.splice(start, step, ...Object.entries(json)); | ||
| for (const key in scope) { | ||
| delete scope[key]; | ||
| } | ||
| for (const [key, value] of group) { | ||
| scope[key] = value; | ||
| } | ||
| return Object.fromEntries(lost); | ||
| } |
| import { count } from './index'; | ||
| export default function (scope, json) { | ||
| const group = Object.entries(scope); | ||
| group.unshift(...Object.entries(json)); | ||
| for (const key in scope) { | ||
| delete scope[key]; | ||
| } | ||
| for (const [key, value] of group) { | ||
| scope[key] = value; | ||
| } | ||
| return count(scope); | ||
| } |
| export default function (scope) { | ||
| return Object.values(scope); | ||
| } |
+124
| 'use strict'; | ||
| // Use APIs | ||
| import * as APIs from './apis'; | ||
| // Json | ||
| export const json = {}; | ||
| // Noop | ||
| export const noop = () => {}; | ||
| // Sync | ||
| export const sync = value => value; | ||
| // Get Prototype | ||
| export const { defineProperty, prototype } = Object; | ||
| // Set Properties | ||
| export const properties = { | ||
| // No Enumerable | ||
| enumerable: false, | ||
| // Can Configure | ||
| configurable: true, | ||
| // Can Writable | ||
| writable: true, | ||
| }; | ||
| /** | ||
| * Functional Empty - Scope is Empty | ||
| * ======== ======== ======== | ||
| * @param scope { json } | ||
| * ======== ======== ======== | ||
| */ | ||
| export const empty = scope => [null, undefined].includes(scope); | ||
| /** | ||
| * Functional Check - Constructor of Scope | ||
| * ======== ======== ======== | ||
| * @param scope { json } | ||
| * ======== ======== ======== | ||
| */ | ||
| export const check = (target, compare) => { | ||
| // Is Empty | ||
| if (empty(target)) { | ||
| return false; | ||
| } | ||
| // Comparing Constructor | ||
| return target.constructor === compare; | ||
| }; | ||
| /** | ||
| * Functional Make - Api Extension for Json | ||
| * ======== ======== ======== | ||
| * @param handler { fn } | ||
| * ======== ======== ======== | ||
| */ | ||
| export const make = (handler, name) => { | ||
| // Use Defined Property | ||
| defineProperty(prototype, name, { | ||
| // Reset Value | ||
| value() { | ||
| // Is Empty | ||
| if (empty(this)) { | ||
| throw new TypeError('Please check if the JSON is correct for ...'); | ||
| } | ||
| // Trigger Handler | ||
| return handler(Object(this), ...arguments); | ||
| }, | ||
| // Applies | ||
| ...properties, | ||
| }); | ||
| }; | ||
| /** | ||
| * Functional Alter - Alter for API | ||
| * ======== ======== ======== | ||
| * @param apis { json } | ||
| * @param alia { string } | ||
| * @param origin { string } | ||
| * ======== ======== ======== | ||
| */ | ||
| export const alter = (apis, alia, origin) => { | ||
| // Check Alia | ||
| if (empty(alia)) { | ||
| return origin; | ||
| } | ||
| // Rename | ||
| apis[alia] = apis[origin]; | ||
| // Clean | ||
| delete apis[origin]; | ||
| // Exporting | ||
| return alia; | ||
| }; | ||
| /** | ||
| * Functional Define | ||
| * ======== ======== ======== | ||
| * @param alias { json } | ||
| * @param apis { modules } | ||
| * ======== ======== ======== | ||
| */ | ||
| export const define = (alias = {}, apis = { ...APIs }) => { | ||
| // Is Defined | ||
| if (define.apis) { | ||
| return define.apis; | ||
| } | ||
| // Best Performance | ||
| for (const name in apis) { | ||
| // Make | ||
| make(apis[name], alter(apis, alias[name], name)); | ||
| } | ||
| // Exposure APIs | ||
| return (define.apis = apis); | ||
| }; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| export { default as jsonasarray } from './src'; | ||
| export { default } from './src'; |
+1
-1
| { | ||
| "name": "jsonasarray", | ||
| "version": "0.0.6", | ||
| "version": "0.0.8", | ||
| "description": "use Json as Array", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+15
-4
@@ -18,3 +18,3 @@ # jsonasarray | ||
| ```js | ||
| import { jsonasarray } from 'jsonasarray'; | ||
| import jsonasarray from 'jsonasarray'; | ||
| ``` | ||
@@ -24,8 +24,19 @@ | ||
| #### 3. use APIs | ||
| #### 3. define APIs | ||
| ```js | ||
| jsonasarray.forEach(x, (value, key) => console.log(key, value)); | ||
| // or | ||
| // define APIs | ||
| jsonasarray(); | ||
| // define alias for APIs | ||
| const apis = jsonasarray({ forEach: 'loop' }); | ||
| ``` | ||
| #### 4. Use | ||
| ```js | ||
| x.forEach((value, key) => console.log(key, value)); | ||
| // or u can also use the original | ||
| apis.loop(x, (value, key) => console.log(key, value)); | ||
| ``` | ||
@@ -32,0 +43,0 @@ |
+2
-8
@@ -1,8 +0,2 @@ | ||
| // Use Preset | ||
| import { factory } from './preset'; | ||
| // Use APIs | ||
| import * as APIs from './api'; | ||
| // Export Prototype | ||
| export default factory(APIs); | ||
| // Import Define for Exposure | ||
| export { define as default } from './code'; |
| export default function (scope) { | ||
| return { ...scope, ...Object.assign({}, ...Array.from(arguments).splice(1)) }; | ||
| } |
| export default function (scope) { | ||
| return Object.keys(scope).length; | ||
| } |
| import count from './count'; | ||
| export default function (scope, callback) { | ||
| const set = []; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| if (callback(value, key, scope) === true) { | ||
| set.push(true); | ||
| } | ||
| } | ||
| return set.length === count(scope); | ||
| } |
| import { noop } from '../preset'; | ||
| export default function (scope, callback = noop) { | ||
| const set = {}; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| if (callback(value, key, scope) === true) { | ||
| set[key] = value; | ||
| } | ||
| } | ||
| return set; | ||
| } |
| import { noop } from '../preset'; | ||
| export default function (scope, callback = noop) { | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| callback(value, key, scope); | ||
| } | ||
| } |
| export default function (scope, value) { | ||
| for (const key in scope) { | ||
| if (scope[key] === value) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } |
| // Count | ||
| export { default as count } from './count'; | ||
| // Loop | ||
| export { default as forEach } from './forEach'; | ||
| export { default as map } from './map'; | ||
| export { default as filter } from './filter'; | ||
| export { default as some } from './some'; | ||
| export { default as every } from './every'; | ||
| // Check | ||
| export { default as includes } from './includes'; | ||
| // Find | ||
| export { default as indexOf } from './indexOf'; | ||
| // Insert | ||
| export { default as unshift } from './unshift'; | ||
| export { default as push } from './push'; | ||
| // Delete | ||
| export { default as shift } from './shift'; | ||
| export { default as pop } from './pop'; | ||
| // Batch | ||
| export { default as slice } from './slice'; | ||
| export { default as splice } from './splice'; | ||
| // Connect | ||
| export { default as concat } from './concat'; | ||
| export { default as join } from './join'; | ||
| // Extension | ||
| export { default as keys } from './keys'; | ||
| export { default as values } from './values'; |
| export default function (scope, value) { | ||
| let index = -1; | ||
| for (const key in scope) { | ||
| index++; | ||
| if (scope[key] === value) { | ||
| return index; | ||
| } | ||
| } | ||
| return index; | ||
| } |
| export default function (scope, separator = ',', mode = 'value') { | ||
| const key = mode === 'value'; | ||
| let set = ''; | ||
| for (const item of Object.entries(scope)) { | ||
| set += `${separator}${item[+key]}`; | ||
| } | ||
| return set.substring(1); | ||
| } |
| export default function (scope) { | ||
| return Object.keys(scope); | ||
| } |
| import { noop } from '../preset'; | ||
| export default function (scope, callback = noop) { | ||
| const set = {}; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| set[key] = callback(value, key, scope); | ||
| } | ||
| return set; | ||
| } |
| export default function (scope) { | ||
| let sign; | ||
| let last; | ||
| for (const key in scope) { | ||
| sign = key; | ||
| } | ||
| last = { [sign]: scope[sign] }; | ||
| delete scope[sign]; | ||
| return last; | ||
| } |
| import count from './count'; | ||
| export default function (scope, json) { | ||
| return Object.assign(scope, json), count(scope); | ||
| } |
| export default function (scope) { | ||
| let first; | ||
| for (const key in scope) { | ||
| first = { [key]: scope[key] }; | ||
| delete scope[key]; | ||
| break; | ||
| } | ||
| return first; | ||
| } |
| import count from './count'; | ||
| export default function (scope, start = 0, step = count(scope) - start) { | ||
| let index = -1; | ||
| let set = {}; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| index++; | ||
| if (index < start) { | ||
| continue; | ||
| } | ||
| if (index >= start + step) { | ||
| break; | ||
| } | ||
| set[key] = value; | ||
| } | ||
| return set; | ||
| } |
| import { noop } from '../preset'; | ||
| export default function (scope, callback = noop) { | ||
| const set = []; | ||
| for (const [key, value] of Object.entries(scope)) { | ||
| if (callback(value, key, scope) === true) { | ||
| set.push(true); | ||
| } | ||
| } | ||
| return !!set.length; | ||
| } |
| import count from './count'; | ||
| export default function (scope, start = 0, step = count(scope) - start, json) { | ||
| const group = Object.entries(scope); | ||
| const lost = group.splice(start, step, ...Object.entries(json)); | ||
| for (const key in scope) { | ||
| delete scope[key]; | ||
| } | ||
| for (const [key, value] of group) { | ||
| scope[key] = value; | ||
| } | ||
| return Object.fromEntries(lost); | ||
| } |
| import count from './count'; | ||
| export default function (scope, json) { | ||
| const group = Object.entries(scope); | ||
| group.unshift(...Object.entries(json)); | ||
| for (const key in scope) { | ||
| delete scope[key]; | ||
| } | ||
| for (const [key, value] of group) { | ||
| scope[key] = value; | ||
| } | ||
| return count(scope); | ||
| } |
| export default function (scope) { | ||
| return Object.values(scope); | ||
| } |
| 'use strict'; | ||
| // Json | ||
| export const json = {}; | ||
| // Noop | ||
| export const noop = () => {}; | ||
| // Sync | ||
| export const sync = (value) => value; | ||
| // Get Prototype | ||
| export const { defineProperty, prototype } = Object; | ||
| // Set Properties | ||
| export const properties = { | ||
| // No Enumerable | ||
| enumerable: false, | ||
| // Can Configure | ||
| configurable: true, | ||
| // Can Writable | ||
| writable: true, | ||
| }; | ||
| /** | ||
| * Functional Empty - Check Scope is Empty | ||
| * ======== ======== ======== | ||
| * @param scope { json } | ||
| * ======== ======== ======== | ||
| */ | ||
| export const empty = (scope) => [null, undefined].includes(scope); | ||
| /** | ||
| * Functional Make - Api Extension for Json | ||
| * ======== ======== ======== | ||
| * @param handler { fn } | ||
| * ======== ======== ======== | ||
| */ | ||
| export const make = (handler, name) => { | ||
| // Use Defined Property | ||
| defineProperty(prototype, name, { | ||
| // Reset Value | ||
| value() { | ||
| // Checking Empty | ||
| if (empty(this)) { | ||
| throw new TypeError('Please check if the JSON is correct for ...'); | ||
| } | ||
| // Trigger Handler | ||
| return handler(Object(this), ...arguments); | ||
| }, | ||
| // Applies | ||
| ...properties, | ||
| }); | ||
| }; | ||
| /** | ||
| * Functional Factory | ||
| * ======== ======== ======== | ||
| * @param apis { modules } | ||
| * ======== ======== ======== | ||
| */ | ||
| export const factory = (apis) => { | ||
| // Extension APIs | ||
| Object.entries(apis).forEach(([name, module]) => make(module, name)); | ||
| // Export APIs | ||
| return apis; | ||
| }; |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
10575
10.16%278
16.81%185
6.32%2
Infinity%