Closed GeorgeS2019 closed 2 years ago
import {
S as e, C as t, P as n, W as o
}
from "./moduleESFormat.js";
Is it possible to define and get => S as e, C as t, P as n, W as o from
var c=await ImportRefAsync("./moduleESFormat.js");
@sps014 I add this code to the index.razor P5Task() function
https://zetcode.com/javascript/lodash/
var d=await ImportRefAsync("https://cdn.skypack.dev/lodash");
var S1=d.PropVal<string>("VERSION");
Console.WriteLine("lodash: version: "+ S1);
var S2=d.CallRef("now");
Console.WriteLine("lodash: now(): "+ S2); //1655416787103
int[] nums = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9};
string nmmsJson = JsonConvert.SerializeObject(nums);
var S3=await d.CallRefAsync("slice", "nmmsJson", 2, 6);
Console.WriteLine("lodash: slice : "+ S3); //["m","s","J","s"] //[ 3, 4, 5, 6 ]
var S4=await d.CallRefAsync("slice", "nmmsJson", 0, 8);
Console.WriteLine("lodash: slice : "+ S4); //["n","m","m","s","J","s","o","n"] //[ 1, 2, 3, 4, 5, 6, 7, 8 ]
how to get [ 3, 4, 5, 6 ] from return string ["m","s","J","s"] ?
Are you trying to get [3-6] sub range, get result as string []
var d=await ImportRefAsync("https://cdn.skypack.dev/lodash");
var S1=d.PropVal<string>("VERSION");
Console.WriteLine("lodash: version: "+ S1);
var S2=d.CallRef("now");
Console.WriteLine("lodash: now(): "+ S2); //1655416787103
int[] nums = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9};
string nmmsJson = JsonSerializer.Serialize(nums);
var S3=await d.CallAsync<string[]>("slice", "nmmsJson", 2, 6);
Console.WriteLine("lodash: slice : "+ string.Join("",S3)); //["m","s","J","s"] //[ 3, 4, 5, 6 ]
var S4=await d.CallAsync<string[]>("slice", "nmmsJson", 0, 8);
Console.WriteLine("lodash: slice : "+ string.Join("",S4)); //["n","m","m","s","J","s","o","n"] //[ 1, 2, 3, 4, 5, 6, 7, 8 ]
The code returns an a string array string[4] of ["m","s","J","s"] instead of a string ["m","s","J","s"]
I wonder what could go wrong that it does not return [ 3, 4, 5, 6 ]
You do not need to need to convert array to json, interop does it internally, also you do not need to pass parameter quoted in string.
var d=await ImportRefAsync("https://cdn.skypack.dev/lodash");
var S1=d.PropVal<string>("VERSION");
Console.WriteLine("lodash: version: "+ S1);
var S2=d.CallRef("now");
Console.WriteLine("lodash: now(): "+ S2); //1655416787103
int[] nums = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9};
var S3=await d.CallAsync<int[]>("slice", nums, 2, 6);
Console.WriteLine("lodash: slice : "+ string.Join(",",S3)); //["m","s","J","s"] //[ 3, 4, 5, 6 ]
var S4=await d.CallAsync<int[]>("slice", nums, 0, 8);
Console.WriteLine("lodash: slice : "+ string.Join(",",S4));
var S3=await d.CallAsync<string[]>("slice", "nmmsJson", 2, 6);
this gives ["m","s","J","s"] from "nm msJs on.
If geven "1, 2, 3, 4, 5, 6, 7, 8, 9"
this gives ["2", ",", "3",","]
I don't think this is a library issue , can you please migrate it in discussion section.
Something must be wrong with lodash I suggest to reproduce with js, and send code so I could replicate, internally I am using this lib in my organization for production app.
Thanks
[add examples of calling function and function with parameters]https://github.com/sps014/BlazorBindGen/blob/66b4d5fba11bb5ae414e86769bcc0eb6a07e5024/SampleApp/Pages/Index.razor#L32