let fruits = new Set(["apples", "bananas", "pears", "oranges"]);
let applesAndBananas = new Set(["apples", "bananas"]);
let applesAndOranges = new Set(["apples", "oranges"]);
let oranges = new Set(["oranges"]);
let emptySet = new Set();
////
// union
////
// Set(4) {'apples', 'bananas', 'pears', 'oranges'}
console.log(fruits.union(oranges));
// Set(3) {'apples', 'bananas', 'oranges'}
console.log(applesAndBananas.union(oranges));
////
// intersection
////
// Set(2) {'apples', 'bananas'}
console.log(fruits.intersection(applesAndBananas));
// Set(0) {}
console.log(applesAndBananas.intersection(oranges));
// Set(1) {'apples'}
console.log(applesAndBananas.intersection(applesAndOranges));
////
// difference
////
// Set(3) {'apples', 'bananas', 'pears'}
console.log(fruits.difference(oranges));
// Set(2) {'pears', 'oranges'}
console.log(fruits.difference(applesAndBananas));
// Set(1) {'bananas'}
console.log(applesAndBananas.difference(applesAndOranges));
////
// symmetricDifference
////
// Set(2) {'bananas', 'oranges'}
console.log(applesAndBananas.symmetricDifference(applesAndOranges)); // no apples
////
// isDisjointFrom
////
// true
console.log(applesAndBananas.isDisjointFrom(oranges));
// false
console.log(applesAndBananas.isDisjointFrom(applesAndOranges));
// true
console.log(fruits.isDisjointFrom(emptySet));
// true
console.log(emptySet.isDisjointFrom(emptySet));
////
// isSubsetOf
////
// true
console.log(applesAndBananas.isSubsetOf(fruits));
// false
console.log(fruits.isSubsetOf(applesAndBananas));
// false
console.log(applesAndBananas.isSubsetOf(oranges));
// true
console.log(fruits.isSubsetOf(fruits));
// true
console.log(emptySet.isSubsetOf(fruits));
////
// isSupersetOf
////
// true
console.log(fruits.isSupersetOf(applesAndBananas));
// false
console.log(applesAndBananas.isSupersetOf(fruits));
// false
console.log(applesAndBananas.isSupersetOf(oranges));
// true
console.log(fruits.isSupersetOf(fruits));
// false
console.log(emptySet.isSupersetOf(fruits));
export function foo() {
// ~~~
// error! Function must have an explicit
// return type annotation with --isolatedDeclarations.
return x;
}
import { add } from "./add";
const x = add();
export function foo() {
return x;
}
// add.d.ts
export declare function add():
add.d.ts
// add.d.ts
export declare function add():
util.ts
// util.ts
export let one = "1";
export let two = "2";
// add.ts
import { one, two } from "./util";
export function add() { return one + two; }
add.ts
wix:image://v1//#originWidth=&originHeight=[&watermark=]
import { media } from "@wix/sdk";
const { url } = media.getImageUrl(wixImageId);
import { createClient, media } from "@wix/sdk";
// ...
const { cart } = await wixClient.currentCart.getCurrentCart();
const { url } = media.getImageUrl(cart.lineItems[0].image);
{
"status": "A",
"$or": [
{
"qty": { "$lt": 30 }
},
{
"item": { "$startsWith": "p" }
}
]
}
{
"tags": ["red", "blank"]
}
{
"tags": "red"
}
{
"item": { "$exists": false }
}
{
"sort": [
{
"fieldName": "sortField1"
},
{
"fieldName": "sortField2",
"order": "DESC"
}
]
}
{
"paging": {
"limit": 20,
"offset": 40
}
}
{
"pagingMetadata": {
"count": 10,
"offset": 0,
"cursors": {
"next": "eyJmaWx0ZXIiOnsiJGFuZCI6W3sibGFuZ3VhZ2UiOnsiJGluIjpbImVuIiwiaGUiXX19LHsic3RhdHVzIjoicHVibGlzaGVkIn1dfSwidmFsdWUiOnsiaXNQaW5uZWQiOmZhbHNlLCJmaXJzdFB1Ymxpc2hlZERhdGUiOiIyMDIyLTA2LTAyVDA2OjQ2OjAyLjgwMloifSwib3JkZXIiOnsiaXNQaW5uZWQiOi0xLCJmaXJzdFB1Ymxpc2hlZERhdGUiOi0xLCJpZCI6LTF9fQ=="
}
}
}
{
"query": {
"cursorPaging": {
"cursor": "eyJmaWx0ZXIiOnsiJGFuZCI6W3sibGFuZ3VhZ2UiOnsiJGluIjpbImVuIiwiaGUiXX19LHsic3RhdHVzIjoicHVibGlzaGVkIn1dfSwidmFsdWUiOnsiaXNQaW5uZWQiOmZhbHNlLCJmaXJzdFB1Ymxpc2hlZERhdGUiOiIyMDIyLTA2LTAyVDA2OjQ2OjAyLjgwM1oifSwib3JkZXIiOnsiaXNQaW5uZWQiOi0xLCJmaXJzdFB1Ymxpc2hlZERhdGUiOi0xLCJpZCI6LTF9fQ"
}
}
}
{
"fields": ["name.firstName", "address"]
}
{
"fieldsets": ["BASIC"]
}
function getClassroomAverage(students: string[], allScores: Map) {
const studentScores = students
.map(student => allScores.get(student))
.filter(score => !!score);
return studentScores.reduce((a, b) => a + b) / studentScores.length;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// error: Object is possibly 'undefined'.
}
function f1(obj: Record, key: string) {
if (typeof obj[key] === "string") {
// Now okay, previously was error
obj[key].toUpperCase();
}
}
/backend/.js(w)/ timed out because it exceeded the maximum execution time.
/** @import * as someModule from "some-module" */
/**
* @param {someModule.SomeType} myValue
*/
function doSomething(myValue) {
// ...
}/**
* @typedef {import("./some-module").SomeType} SomeType
*/
/**
* @param {SomeType} myValue
*/
function doSomething(myValue) {
// ...
}/**
* @param {import("./some-module").SomeType} myValue
*/
function doSomething(myValue) {
// ...
}import * as someModule from "./some-module";
/**
* @param {someModule.SomeType} myValue
*/
function doSomething(myValue) {
// ...
}
/backend/.js(w)/ was throttled because your site exceeded the maximum number of backend requests per minute.
String str = "";
1. Print text data
Add Content; where
B: bold status and value must be 0 if no and 1 if yes
A: align status and value must be 0 if left, 1 if center, 2 if right
F: format type and valune must be 0 if normal, 1 if double Height, 2 if double Height + Width, 3 if double Width
Content: Content is text that you want to print with given format
e.g. str = str + "<110>This is my testing data";
2. Print image
Add A#Base64; where
A: align status and value must be 0 if left, 1 if center, 2 if right
Base64: Base 64 encoded string derived from below function
//Send parameters like pageWidth and filepath where
//pageWidth is page width e.g. 48 for 58mm printer, 72 for 80mm printer
//filePath is complete image file path
private String getBase64(int pageWidth, String filePath) {
//You can modify below program as per your requirements provided that you return base64 string corresponding to the image
//Also check if filepath is not null and your app has required permissions before calling this method
Bitmap bm = BitmapFactory.decodeFile(filePath);
int width = bm.getWidth(), height = bm.getHeight();
int compressValue = 50;
if(width > 500 || height > 500) {
compressValue = 20;
int reqWidth = (int) Math.round(pageWidth * 8);
if (width < reqWidth && width > 16) {
int diff = width % 8;
if (diff != 0) {
int newWidth = width - diff;
int newHeight = (int) (width - diff) * height / width;
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// CREATE A MATRIX FOR THE MANIPULATION
Matrix matrix = new Matrix();
// RESIZE THE BIT MAP
matrix.postScale(scaleWidth, scaleHeight);
// "RECREATE" THE NEW BITMAP
Bitmap resizedBitmap = Bitmap.createBitmap(
bm, 0, 0, width, height, matrix, false);
if (bm != null && !bm.isRecycled())
bm.recycle();
bm = resizedBitmap;
}
} else if (width > 16) {
int newHeight = (int) reqWidth * height / width;
float scaleWidth = ((float) reqWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// CREATE A MATRIX FOR THE MANIPULATION
Matrix matrix = new Matrix();
// RESIZE THE BIT MAP
matrix.postScale(scaleWidth, scaleHeight);
// "RECREATE" THE NEW BITMAP
Bitmap resizedBitmap = Bitmap.createBitmap(
bm, 0, 0, width, height, matrix, false);
if (bm != null && !bm.isRecycled())
bm.recycle();
bm = resizedBitmap;
}
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, compressValue, byteArrayOutputStream); // bm is the bitmap object
return Base64.encodeToString(byteArrayOutputStream.toByteArray(), Base64.DEFAULT);
}
3. Print Barcode
Add A#W#H#Value; where
A: align status and value must be 0 if left, 1 if center, 2 if right
W: Valid barcode width
H: Valid barcode height
Value: Valid barcode value
e.g. str = str + "0#100#50#2132137538472";
4. Print QR Code
Add A#S#Value; where
A: align status and value must be 0 if left, 1 if center, 2 if right
S: QR Code Size
Value: Valid QR Code value
e.g. str = str + "1#50#This is sample";
5. Print HTML
Add Code where
Code: This is an HTML code to be printed; Put escape character before "
e.g. str = str + "" + getHTMLEquivalent("
This is left
This is right
");
Add below function for HTML
private String getHTMLEquivalent(String s) {
return s.replaceAll("<","<").replaceAll(">",">");
}
To say in simple words, You can create an example string like below
String imgpath = Environment.getExternalStorageDirectory().toString()+"/BluetoothPrint/test.jpg";
String str = "<113>Mate Technologies<100>Website: www.matetech.in\nEmail: matetusshar@gmail.com1#"+imgpath;
str = str + "0#100#50#21321375384721#40#testing text";
str = str + "
This is left
This is right
";
Just pass this to Bluetooth Print app using Intent below
//check if app is already installed to avoid crash
if(appInstalled){
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setPackage("mate.bluetoothprint");
sendIntent.putExtra(Intent.EXTRA_TEXT, str);
sendIntent.setType("text/plain");
startActivity(sendIntent);
}
// ./some-module.d.ts
export interface SomeType {
// ...
}
// ./index.js
import { SomeType } from "./some-module"; // ❌ runtime error!
/**
* @param {SomeType} myValue
*/
function doSomething(myValue) {
// ...
}
function createSecret(secret: Secret): Promise;
import { secrets } from "wix-secrets-backend.v2";
import { elevate } from "wix-auth";
export function createNewSecret() {
const secret = {
name: "s3_secret_key",
value: "Fm8OfflH6bJOwWjenqAtLurLbkiMNvmhQHZV+118",
description: "AWS secret access key",
};
const elevatedCreateSecret = elevate(secrets.createSecret);
return elevatedCreateSecret(secret)
.then((id) => {
return id;
})
.catch((error) => {
console.error(error);
});
}
/*
* Returns a Promise that resolves to:
*
* "5ec36ffb-2cec-489a-9c0e-d8f53fef5fd1"
*/
{
"data": {
"eventType": "OrderPaid",
"instanceId": "",
"data": "",
// The identity field is sent as a stringified JSON
"identity": {
"identityType": "", // ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP
"anonymousVisitorId": "", // in case of ANONYMOUS_VISITOR
"memberId": "", // in case of MEMBER
"wixUserId": "", // in case of WIX_USER
"appId": "" // in case of APP
}
}
}