Funzionalità di runtime JavaScript 2.0 per Funzioni CloudFront
L'ambiente runtime JavaScript di CloudFront Functions è compatibile con ECMAScript (ES) versione 5.1
Argomenti
Caratteristiche principali
Sono supportate le seguenti caratteristiche principali di ES.
- Tipi
-
Sono supportati tutti i tipi ES 5.1. Tra questi vi sono valori booleani, numeri, stringhe, oggetti, matrici, funzioni ed espressioni regolari.
- Operatori
-
Sono supportati tutti gli operatori ES 5.1.
È supportato l'operatore esponenziale ES 7 (
**). - Dichiarazioni
-
Sono supportate le seguenti istruzioni ES 5.1:
-
break -
catch -
continue -
do-while -
else -
finally -
for -
for-in -
if -
label -
return -
switch -
throw -
try -
var -
while
Sono supportate le seguenti istruzioni ES 6:
-
const -
let
Sono supportate le seguenti istruzioni ES 8:
async-
await
Nota
async,await,consteletsono supportati nel runtime JavaScript 2.0.awaitpuò essere utilizzato solo all’interno delle funzioniasync. Argomenti e chiusureasyncnon sono supportati. -
- Valori letterali
-
Sono supportati i valori letterali modello ES 6: stringhe multilinea, interpolazione di espressioni e modelli di nidificazione.
- Funzioni
-
Sono supportate tutte le funzioni ES 5.1.
Sono supportate le funzioni freccia ES 6 ed è supportata la sintassi del parametro rest ES 6.
- Unicode
-
Il testo di origine e i valori letterali stringa possono contenere caratteri codificati in Unicode. Sono supportate anche sequenze di escape dei punti di codice Unicode di sei caratteri (ad esempio,
\uXXXX). - Modalità rigorosa
-
Le funzioni funzionano in modalità rigorosa per impostazione predefinita, quindi non è necessario aggiungere una istruzione
use strictnel codice funzione. Non possono essere modificate.
Oggetti primitivi
Sono supportati i seguenti oggetti primitivi di ES.
- Oggetto
-
Sono supportati i seguenti metodi ES 5.1 sugli oggetti:
-
Object.create()(senza elenco delle proprietà) -
Object.defineProperties() -
Object.defineProperty() -
Object.freeze() -
Object.getOwnPropertyDescriptor() -
Object.getOwnPropertyDescriptors() -
Object.getOwnPropertyNames() -
Object.getPrototypeOf() -
Object.isExtensible() -
Object.isFrozen() -
Object.isSealed() -
Object.keys() -
Object.preventExtensions() -
Object.seal()
Sono supportati i seguenti metodi ES 6 sugli oggetti:
-
Object.assign()
Sono supportati i seguenti metodi ES 8 sugli oggetti:
-
Object.entries() -
Object.values()
Sono supportati i seguenti metodi di prototipo ES 5.1 sugli oggetti:
-
Object.prototype.hasOwnProperty() -
Object.prototype.isPrototypeOf() -
Object.prototype.propertyIsEnumerable() -
Object.prototype.toString() -
Object.prototype.valueOf()
Sono supportati i seguenti metodi di prototipo ES 6 sugli oggetti:
-
Object.prototype.is() -
Object.prototype.setPrototypeOf()
-
- Stringa
-
Sono supportati i seguenti metodi ES 5.1 sulle stringhe:
String.fromCharCode()
Sono supportati i seguenti metodi ES 6 sulle stringhe:
String.fromCodePoint()
Sono supportati i seguenti metodi di prototipo ES 5.1 sulle stringhe:
-
String.prototype.charAt() -
String.prototype.concat() -
String.prototype.indexOf() -
String.prototype.lastIndexOf() -
String.prototype.match() -
String.prototype.replace() -
String.prototype.search() -
String.prototype.slice() -
String.prototype.split() -
String.prototype.substr() -
String.prototype.substring() -
String.prototype.toLowerCase() -
String.prototype.trim() -
String.prototype.toUpperCase()
Sono supportati i seguenti metodi di prototipo ES 6 sulle stringhe:
-
String.prototype.codePointAt() -
String.prototype.endsWith() -
String.prototype.includes() -
String.prototype.repeat() -
String.prototype.startsWith()
Sono supportati i seguenti metodi di prototipo ES 8 sulle stringhe:
-
String.prototype.padStart() -
String.prototype.padEnd()
Sono supportati i seguenti metodi di prototipo ES 9 sulle stringhe:
-
String.prototype.trimStart() -
String.prototype.trimEnd()
Sono supportati i seguenti metodi di prototipo ES 12 sulle stringhe:
String.prototype.replaceAll()Nota
String.prototype.replaceAll()rappresenta una novità nel runtime JavaScript 2.0.
- Numero
-
Sono supportati TUTTI i numeri ES 5.
Sono supportate le seguenti proprietà ES 6 sui numeri:
Number.EPSILON-
Number.MAX_SAFE_INTEGER -
Number.MIN_SAFE_INTEGER -
Number.MAX_VALUE -
Number.MIN_VALUE -
Number.NaN -
Number.NEGATIVE_INFINITY -
Number.POSITIVE_INFINITY
Sono supportati i seguenti metodi ES 6 sui numeri:
-
Number.isFinite() -
Number.isInteger() -
Number.isNaN() -
Number.isSafeInteger() -
Number.parseInt() -
Number.parseFloat()
Sono supportati i seguenti metodi di prototipo ES 5.1 sui numeri:
-
Number.prototype.toExponential() -
Number.prototype.toFixed() -
Number.prototype.toPrecision()
Sono supportati i separatori numerici ES 12.
Nota
I separatori numerici ES 12 rappresentano una novità nel runtime JavaScript 2.0.
Oggetti incorporati
Sono supportati i seguenti oggetti incorporati di ES.
- Math
-
Sono supportati tutti i metodi matematici ES 5.1.
Nota
Nell'ambiente runtime CloudFront Functions, l'implementazione
Math.random()utilizza OpenBSDarc4randompredefinito con il timestamp di quando viene eseguita la funzione.Sono supportate le seguenti proprietà matematiche ES 6:
-
Math.E -
Math.LN10 -
Math.LN2 -
Math.LOG10E -
Math.LOG2E -
Math.PI -
Math.SQRT1_2 -
Math.SQRT2
Sono supportati i seguenti metodi matematici ES 6:
-
Math.abs() -
Math.acos() -
Math.acosh() -
Math.asin() -
Math.asinh() -
Math.atan() -
Math.atan2() -
Math.atanh() -
Math.cbrt() -
Math.ceil() -
Math.clz32() -
Math.cos() -
Math.cosh() -
Math.exp() -
Math.expm1() -
Math.floor() -
Math.fround() -
Math.hypot() -
Math.imul() -
Math.log() -
Math.log1p() -
Math.log2() -
Math.log10() -
Math.max() -
Math.min() -
Math.pow() -
Math.random() -
Math.round() -
Math.sign() -
Math.sinh() -
Math.sin() -
Math.sqrt() -
Math.tan() -
Math.tanh() -
Math.trunc()
-
- Data
-
Sono supportate tutte le funzioni
DateES 5.1.Nota
Per motivi di sicurezza, restituisce
Datesempre lo stesso valore, ovvero l'ora di inizio della funzione, durante la durata di una singola esecuzione di una funzione. Per ulteriori informazioni, consulta Funzionalità con restrizioni. - Funzione
-
Sono supportati i seguenti metodi di prototipo ES 5.1:
Function.prototype.apply()-
Function.prototype.bind() -
Function.prototype.call()
I costruttori di funzioni non sono supportati.
- Espressioni regolari
-
Sono supportate tutte le funzioni di espressione regolare ES 5.1. Il linguaggio delle espressioni regolari è compatibile con Perl.
Sono supportate le seguenti proprietà di accessor per prototipo ES 5.1:
-
RegExp.prototype.global -
RegExp.prototype.ignoreCase -
RegExp.protoype.multiline -
RegExp.protoype.source -
RegExp.prototype.sticky -
RegExp.prototype.flagsNota
RegExp.prototype.stickyeRegExp.prototype.flagsrappresentano delle novità nel runtime JavaScript 2.0.
Sono supportati i seguenti metodi di prototipo ES 5.1:
-
RegExp.prototype.exec() -
RegExp.prototype.test() -
RegExp.prototype.toString() -
RegExp.prototype[@@replace]() -
RegExp.prototype[@@split]()Nota
RegExp.prototype[@@split]()rappresenta una novità nel runtime JavaScript 2.0.
Sono supportate le seguenti proprietà di istanza ES 5.1:
-
lastIndex
Sono supportati i gruppi di acquisizione denominati di ES 9.
-
- JSON
-
Sono supportati i seguenti metodi ES 5.1:
-
JSON.parse() -
JSON.stringify()
-
- Array
-
Sono supportati i seguenti metodi ES 5.1 sugli array:
-
Array.isArray()
Sono supportati i seguenti metodi ES 6 sugli array:
-
Array.of()
Sono supportati i seguenti metodi di prototipo ES 5.1:
-
Array.prototype.concat() -
Array.prototype.every() -
Array.prototype.filter() -
Array.prototype.forEach() -
Array.prototype.indexOf() -
Array.prototype.join() -
Array.prototype.lastIndexOf() -
Array.prototype.map() -
Array.prototype.pop() -
Array.prototype.push() -
Array.prototype.reduce() -
Array.prototype.reduceRight() -
Array.prototype.reverse() -
Array.prototype.shift() -
Array.prototype.slice() -
Array.prototype.some() -
Array.prototype.sort() -
Array.prototype.splice() -
Array.prototype.unshift()
Sono supportati i seguenti metodi di prototipo ES 6:
-
Array.prototype.copyWithin() -
Array.prototype.fill() -
Array.prototype.find() -
Array.prototype.findIndex()
Sono supportati i seguenti metodi di prototipo ES 7:
Array.prototype.includes()
-
- Array tipizzati
-
Sono supportati i seguenti costruttori di array tipizzati ES 6:
-
Float32Array -
Float64Array -
Int8Array -
Int16Array -
Int32Array -
Uint8Array -
Uint8ClampedArray -
Uint16Array -
Uint32Array
Sono supportati i seguenti metodi ES 6:
-
TypedArray.from() -
TypedArray.of()Nota
TypedArray.from()eTypedArray.of()rappresentano delle novità nel runtime JavaScript 2.0.
Sono supportati i seguenti metodi di prototipo ES 6:
-
TypedArray.prototype.copyWithin() -
TypedArray.prototype.every() -
TypedArray.prototype.fill() -
TypedArray.prototype.filter() -
TypedArray.prototype.find() -
TypedArray.prototype.findIndex() -
TypedArray.prototype.forEach() -
TypedArray.prototype.includes() -
TypedArray.prototype.indexOf() -
TypedArray.prototype.join() -
TypedArray.prototype.lastIndexOf() -
TypedArray.prototype.map() -
TypedArray.prototype.reduce() -
TypedArray.prototype.reduceRight() -
TypedArray.prototype.reverse() -
TypedArray.prototype.some() -
TypedArray.prototype.set() -
TypedArray.prototype.slice() -
TypedArray.prototype.sort() -
TypedArray.prototype.subarray() -
TypedArray.prototype.toString()Nota
TypedArray.prototype.every(),TypedArray.prototype.fill(),TypedArray.prototype.filter(),TypedArray.prototype.find(),TypedArray.prototype.findIndex(),TypedArray.prototype.forEach(),TypedArray.prototype.includes(),TypedArray.prototype.indexOf(),TypedArray.prototype.join(),TypedArray.prototype.lastIndexOf(),TypedArray.prototype.map(),TypedArray.prototype.reduce(),TypedArray.prototype.reduceRight(),TypedArray.prototype.reverse()eTypedArray.prototype.some()rappresentano delle novità nel runtime JavaScript 2.0.
-
- ArrayBuffer
-
Sono supportati i seguenti metodi ES 6 su ArrayBuffer:
-
isView()
Sono supportati i seguenti metodi di prototipo ES 6 su ArrayBuffer:
-
ArrayBuffer.prototype.slice()
-
- Promessa
-
Sono supportati i seguenti metodi ES 6 sulle promesse:
-
Promise.all() -
Promise.allSettled() -
Promise.any() -
Promise.reject() -
Promise.resolve() -
Promise.race()Nota
Promise.all(),Promise.allSettled(),Promise.any()ePromise.race()rappresentano delle novità nel runtime JavaScript 2.0.
Sono supportati i seguenti metodi di prototipo ES 6 sulle promesse:
-
Promise.prototype.catch() -
Promise.prototype.finally() -
Promise.prototype.then()
-
- DataView
-
Sono supportati i seguenti metodi di prototipo ES 6:
-
DataView.prototype.getFloat32() -
DataView.prototype.getFloat64() -
DataView.prototype.getInt16() -
DataView.prototype.getInt32() -
DataView.prototype.getInt8() -
DataView.prototype.getUint16() -
DataView.prototype.getUint32() -
DataView.prototype.getUint8() -
DataView.prototype.setFloat32() -
DataView.prototype.setFloat64() -
DataView.prototype.setInt16() -
DataView.prototype.setInt32() -
DataView.prototype.setInt8() -
DataView.prototype.setUint16() -
DataView.prototype.setUint32() -
DataView.prototype.setUint8()Nota
Tutti i metodi di prototipo DataView ES 6 rappresentano delle novità nel runtime JavaScript 2.0.
-
- Symbol
-
Sono supportati i seguenti metodi ES 6:
-
Symbol.for() -
Symbol.keyfor()Nota
Tutti i metodi Symbol ES 6 rappresentano delle novità nel runtime JavaScript 2.0.
-
- TextDecoder
-
Sono supportati i seguenti metodi di prototipo:
-
TextDecoder.prototype.decode()
Sono supportate le seguenti proprietà di accessor per prototipo:
-
TextDecoder.prototype.encoding -
TextDecoder.prototype.fatal -
TextDecoder.prototype.ignoreBOM
-
- TextEncoder
-
Sono supportati i seguenti metodi di prototipo:
-
TextEncoder.prototype.encode() -
TextEncoder.prototype.encodeInto()
-
Tipi di errore
Sono supportati i seguenti oggetti di errore:
-
Error -
EvalError -
InternalError -
RangeError -
ReferenceError -
SyntaxError -
TypeError -
URIError
Elementi globali
L'oggetto globalThis è supportato.
Sono supportate le seguenti funzioni globali ES 5.1:
-
decodeURI() -
decodeURIComponent() -
encodeURI() -
encodeURIComponent() -
isFinite() -
isNaN() -
parseFloat() -
parseInt()
Sono supportate le seguenti funzioni globali ES 6:
atob()-
btoa()Nota
atob()ebtoa()rappresentano delle novità nel runtime JavaScript 2.0.
Sono supportate le seguenti costanti globali:
-
NaN -
Infinity -
undefined -
arguments
Moduli incorporati
Sono supportati i seguenti moduli incorporati:
Buffer
Il modulo fornisce i metodi seguenti:
-
Buffer.alloc(size[, fill[, encoding]])Alloca un
Buffer.-
size: dimensione del buffer. Immetti un numero intero. -
fill: facoltativo. Immetti una stringa,Buffer, Uint8Array o un numero intero. Il valore predefinito è “”.0. -
encoding: facoltativo. Quandofillè una stringa, immetti uno dei seguenti valori:utf8,hex,base64,base64url. Il valore predefinito è “”.utf8.
-
-
Buffer.allocUnsafe(size)Alloca un
Buffernon inizializzato.-
size: immetti un numero intero.
-
-
Buffer.byteLength(value[, encoding])Restituisce la lunghezza di un valore, in byte.
-
value: una stringa,Buffer, TypedArray, Dataview o Arraybuffer. -
encoding: facoltativo. Quandovalueè una stringa, immetti uno dei seguenti valori:utf8,hex,base64,base64url. Il valore predefinito è “”.utf8.
-
-
Buffer.compare(buffer1, buffer2)Confronta due
Bufferper semplificare l'ordinamento degli array. Restituisce0se sono uguali,-1se viene primabuffer1o1se viene primabuffer2.-
buffer1: immetti unBuffer. -
buffer2: immetti un altroBuffer.
-
-
Buffer.concat(list[, totalLength])Concatena più
Buffer. Restituisce0se non ce ne sono. Restituisce fino atotalLength.-
list: immetti un elenco diBuffer. Tieni presente che verrà troncato atotalLength. -
totalLength: facoltativo. Inserisci un numero intero senza segno. Usa la somma delle istanzeBuffernell'elenco se vuoto.
-
-
Buffer.from(array)Crea un
Bufferda un array.-
array: immetti un array di byte da0a255.
-
-
Buffer.from(arrayBuffer, byteOffset[, length]))Crea una vista da
arrayBuffer, partendo dall'offsetbyteOffsetcon lunghezzalength.-
arrayBuffer: immetti una matriceBuffer. -
byteOffset: immetti un numero intero. -
length: facoltativo. Immetti un numero intero.
-
-
Buffer.from(buffer)Crea una copia del
Buffer.-
buffer: immetti unBuffer.
-
-
Buffer.from(object[, offsetOrEncoding[, length]])Crea un
Bufferda un oggetto. RestituisceBuffer.from(object.valueOf(), offsetOrEncoding, length)sevalueOf()non è uguale all'oggetto.-
object: immetti un oggetto. -
offsetOrEncoding: facoltativo. Immetti un numero intero o una stringa di codifica. -
length: facoltativo. Immetti un numero intero.
-
-
Buffer.from(string[, encoding])Crea un
Bufferda una stringa.-
string: immetti una stringa. -
encoding: facoltativo. Immetti uno dei seguenti valori:utf8,hex,base64,base64url. Il valore predefinito è “”.utf8.
-
-
Buffer.isBuffer(object)Controlla se
objectè un buffer. Restituiscetrueofalse.-
object: immetti un oggetto.
-
-
Buffer.isEncoding(encoding)Verifica se
encodingè supportato. Restituiscetrueofalse.-
encoding: facoltativo. Immetti uno dei seguenti valori:utf8,hex,base64,base64url. Il valore predefinito è “”.utf8.
-
Il modulo fornisce i seguenti metodi di prototipo del buffer:
-
Buffer.prototype.compare(target[, targetStart[, targetEnd[, sourceStart[, sourceEnd]]]])Confronta
Buffercon l'obiettivo. Restituisce0se sono uguali,1se viene primabuffero-1se viene primatarget.-
target: immetti unBuffer. -
targetStart: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
targetEnd: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza ditarget. -
sourceStart: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
sourceEnd: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza diBuffer.
-
-
Buffer.prototype.copy(target[, targetStart[, sourceStart[, sourceEnd]]])Copia il buffer su
target.-
target: immetti unBufferoUint8Array. -
targetStart: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
sourceStart: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
sourceEnd: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza diBuffer.
-
-
Buffer.prototype.equals(otherBuffer)Confronta
BufferconotherBuffer. Restituiscetrueofalse.-
otherBuffer: immetti una stringa.
-
-
Buffer.prototype.fill(value[, offset[, end][, encoding])Compila
Bufferconvalue.-
value: immetti una stringa,Buffero un numero intero. -
offset: facoltativo. Immetti un numero intero. -
end: facoltativo. Immetti un numero intero. -
encoding: facoltativo. Immetti uno dei seguenti valori:utf8,hex,base64,base64url. Il valore predefinito è “”.utf8.
-
-
Buffer.prototype.includes(value[, byteOffset][, encoding])Cerca
valueinBuffer. Restituiscetrueofalse.-
value: immetti una stringa,Buffer,Uint8Arrayo un numero intero. -
byteOffset: facoltativo. Immetti un numero intero. -
encoding: facoltativo. Immetti uno dei seguenti valori:utf8,hex,base64,base64url. Il valore predefinito è “”.utf8.
-
-
Buffer.prototype.indexOf(value[, byteOffset][, encoding])Cerca il primo
valueinBuffer. Restituisceindexse trovato e-1se non trovato.-
value: immetti una stringa,Buffer, Unit8Array o un numero intero compreso tra 0 e 255. -
byteOffset: facoltativo. Immetti un numero intero. -
encoding: facoltativo. Sevalueè una stringa, immetti uno dei seguenti valori:utf8,hex,base64,base64url. Il valore predefinito è “”.utf8.
-
-
Buffer.prototype.lastIndexOf(value[, byteOffset][, encoding])Cerca l'ultimo
valueinBuffer. Restituisceindexse trovato e-1se non trovato.-
value: immetti una stringa,Buffer, Unit8Array o un numero intero compreso tra 0 e 255. -
byteOffset: facoltativo. Immetti un numero intero. -
encoding: facoltativo. Sevalueè una stringa, immetti uno dei seguenti valori:utf8,hex,base64,base64url. Il valore predefinito è “”.utf8.
-
-
Buffer.prototype.readInt8(offset)Leggi
Int8inoffseta partire daBuffer.-
offset: immetti un numero intero.
-
-
Buffer.prototype.readIntBE(offset, byteLength)Leggi
Intcome big-endian inoffsetdaBuffer.-
offset: immetti un numero intero. -
byteLength: facoltativo. Immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.readInt16BE(offset)Leggi
Int16come big-endian inoffsetdaBuffer.-
offset: immetti un numero intero.
-
-
Buffer.prototype.readInt32BE(offset)Leggi
Int32come big-endian inoffsetdaBuffer.-
offset: immetti un numero intero.
-
-
Buffer.prototype.readIntLE(offset, byteLength)Leggi
Intcome little-endian inoffsetdaBuffer.-
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.readInt16LE(offset)Leggi
Int16come little-endian inoffsetdaBuffer.-
offset: immetti un numero intero.
-
-
Buffer.prototype.readInt32LE(offset)Leggi
Int32come little-endian inoffsetdaBuffer.-
offset: immetti un numero intero.
-
-
Buffer.prototype.readUInt8(offset)Leggi
UInt8inoffseta partire daBuffer.-
offset: immetti un numero intero.
-
-
Buffer.prototype.readUIntBE(offset, byteLength)Leggi
UIntcome big-endian inoffsetdaBuffer.-
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.readUInt16BE(offset)Leggi
UInt16come big-endian inoffsetdaBuffer. -
-
offset: immetti un numero intero.
-
-
Buffer.prototype.readUInt32BE(offset)Leggi
UInt32come big-endian inoffsetdaBuffer.-
offset: immetti un numero intero.
-
-
Buffer.prototype.readUIntLE(offset, byteLength)Leggi
UIntcome little-endian inoffsetdaBuffer.-
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.readUInt16LE(offset)Leggi
UInt16come little-endian inoffsetdaBuffer.-
offset: immetti un numero intero.
-
-
Buffer.prototype.readUInt32LE(offset)Leggi
UInt32come little-endian inoffsetdaBuffer.-
offset: immetti un numero intero.
-
-
Buffer.prototype.readDoubleBE([offset])Leggi un file a doppia precisione a 64 bit come big-endian in
offsetdaBuffer.-
offset: facoltativo. Immetti un numero intero.
-
-
Buffer.prototype.readDoubleLE([offset])Leggi un file a doppia precisione a 64 bit come little-endian in
offsetdaBuffer.-
offset: facoltativo. Immetti un numero intero.
-
-
Buffer.prototype.readFloatBE([offset])Leggi un file a virgola mobile a 32 bit come big-endian in
offsetdaBuffer.-
offset: facoltativo. Immetti un numero intero.
-
-
Buffer.prototype.readFloatLE([offset])Leggi un file a virgola mobile a 32 bit come little-endian in
offsetdaBuffer.-
offset: facoltativo. Immetti un numero intero.
-
-
Buffer.prototype.subarray([start[, end]])Restituisce una copia di
Buffercon offset e ritaglio con nuovi valori perstarteend.-
start: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
end: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza del buffer.
-
-
Buffer.prototype.swap16()Scambia l'ordine dei byte dell'array
Buffer, trattandolo come un array di numeri a 16 bit. La lunghezza diBufferdeve essere divisibile per 2, altrimenti riceverai un errore. -
Buffer.prototype.swap32()Scambia l'ordine dei byte dell'array
Buffer, trattandolo come un array di numeri a 32 bit. La lunghezza diBufferdeve essere divisibile per 4, altrimenti riceverai un errore. -
Buffer.prototype.swap64()Scambia l'ordine dei byte dell'array
Buffer, trattandolo come un array di numeri a 64 bit. La lunghezza diBufferdeve essere divisibile per 8, altrimenti riceverai un errore. -
Buffer.prototype.toJSON()Restituisce
Buffercome file JSON. -
Buffer.prototype.toString([encoding[, start[, end]]])Converti
Buffer, dastartaend, in una stringa codificata.-
encoding: facoltativo. Immetti uno dei seguenti valori:utf8,hex,base64obase64url. Il valore predefinito è “”.utf8. -
start: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
end: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza del buffer.
-
-
Buffer.prototype.write(string[, offset[, length]][, encoding])Scrivi il valore
stringcodificato suBufferse c'è spazio a sufficienza o un valorestringtroncato se non c'è abbastanza spazio.-
string: immetti una stringa. -
offset: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
length: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza della stringa. -
encoding: facoltativo. Facoltativamente, immetti uno dei seguenti valori:utf8,hex,base64obase64url. Il valore predefinito è “”.utf8.
-
-
Buffer.prototype.writeInt8(value, offset, byteLength)Scrivi
Int8valuedibyteLengthaoffsetsuBuffer.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeIntBE(value, offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo big-endian.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeInt16BE(value, offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo big-endian.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeInt32BE(value, offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo big-endian.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeIntLE(offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo little-endian.-
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeInt16LE(offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo little-endian.-
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeInt32LE(offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo little-endian.-
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeUInt8(value, offset, byteLength)Scrivi
UInt8valuedibyteLengthaoffsetsuBuffer.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeUIntBE(value, offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo big-endian.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeUInt16BE(value, offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo big-endian.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeUInt32BE(value, offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo big-endian.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeUIntLE(value, offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo little-endian.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeUInt16LE(value, offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo little-endian.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeUInt32LE(value, offset, byteLength)Scrivi
valueaoffsetsuBuffer, usando il metodo little-endian.-
value: immetti un numero intero. -
offset: immetti un numero intero. -
byteLength: immetti un numero intero compreso tra1e6.
-
-
Buffer.prototype.writeDoubleBE(value, [offset])Scrivi
valueaoffsetsuBuffer, usando il metodo big-endian.-
value: immetti un numero intero. -
offset: facoltativo. Immetti un numero intero. Il valore predefinito è 0.
-
-
Buffer.prototype.writeDoubleLE(value, [offset])Scrivi
valueaoffsetsuBuffer, usando il metodo little-endian.-
value: immetti un numero intero. -
offset: facoltativo. Immetti un numero intero. Il valore predefinito è 0.
-
-
Buffer.prototype.writeFloatBE(value, [offset])Scrivi
valueaoffsetsuBuffer, usando il metodo big-endian.-
value: immetti un numero intero. -
offset: facoltativo. Immetti un numero intero. Il valore predefinito è 0.
-
-
Buffer.prototype.writeFloatLE(value, [offset])Scrivi
valueaoffsetsuBuffer, usando il metodo little-endian.-
value: immetti un numero intero. -
offset: facoltativo. Immetti un numero intero. Il valore predefinito è 0.
-
Sono supportati i seguenti metodi di istanza:
-
buffer[index]Ottieni e imposta l'ottetto (byte) a
indexinBuffer.-
Ottieni un numero da
0a255. In alternativa, imposta un numero da0a255.
-
Sono supportate le seguenti proprietà di istanza:
-
bufferOttieni l'oggetto
ArrayBufferper il buffer. -
byteOffsetOttieni il valore
byteOffsetper l'oggettoArraybufferdel buffer. -
lengthOttieni il conteggio dei byte del buffer.
Nota
Tutti i metodi del modulo Buffer rappresentano delle novità nel runtime JavaScript 2.0.
Stringa di query
Nota
L'oggetto evento di CloudFront Functions analizza automaticamente le stringhe di query URL per tuo conto. Ciò significa che nella maggior parte dei casi non è necessario utilizzare questo modulo.
Il modulo stringa di query (querystring) fornisce metodi per l'analisi e la formattazione delle stringhe di query URL. È possibile caricare il modulo usando require('querystring'). Il modulo fornisce i metodi seguenti:
querystring.escape(string)-
URL che codifica il dato
string, restituendo una stringa di query con escape. Il metodo viene utilizzato daquerystring.stringify()e non deve essere utilizzato direttamente. querystring.parse(string[, separator[, equal[, options]]])-
Analizza una stringa di query (
string) e restituisce un oggetto.Il parametro
separatorè una sottostringa per delimitare coppie chiave e valore nella stringa di query. Per impostazione predefinita, tale valore è&.Il parametro
equalè una sottostringa per la delimitazione di chiavi e valori nella stringa di query. Per impostazione predefinita, tale valore è=.Il parametro
optionsè un oggetto con le seguenti chiavi:decodeURIComponent function-
Un funzione per decodificare i caratteri codificati in percentuale nella stringa di query. Per impostazione predefinita, tale valore è
querystring.unescape(). maxKeys number-
Il numero massimo di chiavi da analizzare. Per impostazione predefinita, tale valore è
1000. Utilizza un valore0per rimuovere le limitazioni per il conteggio delle chiavi.
Per impostazione predefinita, si presuppone che i caratteri con codifica in percentuale all'interno della stringa di query utilizzino la codifica UTF-8. Le sequenze UTF-8 non valide vengono sostituite con il carattere sostitutivo
U+FFFD.Ad esempio, per la seguente stringa di query:
'name=value&abc=xyz&abc=123'Il valore restituito di
querystring.parse()è:{ name: 'value', abc: ['xyz', '123'] }querystring.decode()è un alias perquerystring.parse(). querystring.stringify(object[, separator[, equal[, options]]])-
Serializza un
objecte restituisce una stringa di query.Il parametro
separatorè una sottostringa per delimitare coppie chiave e valore nella stringa di query. Per impostazione predefinita, tale valore è&.Il parametro
equalè una sottostringa per la delimitazione di chiavi e valori nella stringa di query. Per impostazione predefinita, tale valore è=.Il parametro
optionsè un oggetto con le seguenti chiavi:encodeURIComponent function-
La funzione da utilizzare per convertire caratteri non sicuri dell’URL in codifica percentuale nella stringa di query. Per impostazione predefinita, tale valore è
querystring.escape().
Per impostazione predefinita, i caratteri che richiedono la codifica percentuale all'interno della stringa di query sono codificati come UTF-8. Per utilizzare una codifica diversa, specifica l'opzione
encodeURIComponent.Ad esempio, per il seguente codice:
querystring.stringify({ name: 'value', abc: ['xyz', '123'], anotherName: '' });Il valore restituito è:
'name=value&abc=xyz&abc=123&anotherName='querystring.encode()è un alias perquerystring.stringify(). querystring.unescape(string)-
Decodifica i caratteri codificati in percentuale URL nel dato
string, restituendo una stringa di query senza escape. Questo metodo viene utilizzato daquerystring.parse()e non deve essere utilizzato direttamente.
Crittografia
Il modulo di crittografia (crypto) fornisce helper di hashing standard e HMAC (Hash Message Authentication Code). È possibile caricare il modulo usando require('crypto').
Metodi di hashing
crypto.createHash(algorithm)-
Crea e restituisce un oggetto hash che è possibile utilizzare per generare digest hash utilizzando il dato algoritmo:
md5,sha1, osha256. hash.update(data)-
Aggiorna il contenuto hash con il dato
data. hash.digest([encoding])-
Calcola il digest di tutti i dati passati tramite
hash.update(). La codifica può esserehex,base64obase64url.
Metodi HMAC
crypto.createHmac(algorithm, secret key)-
Crea e restituisce un oggetto HMAC che utilizza il dato
algorithmesecret key. L'algoritmo può esseremd5,sha1osha256. hmac.update(data)-
Aggiorna il contenuto HMAC con il dato
data. hmac.digest([encoding])-
Calcola il digest di tutti i dati passati tramite
hmac.update(). La codifica può esserehex,base64obase64url.
Funzionalità con restrizioni
Le seguenti funzionalità del linguaggio JavaScript non sono supportate o sono limitate a causa di problemi di sicurezza.
- Valutazione dinamica del codice
-
La valutazione dinamica del codice non è supportata. Entrambi i costruttori
eval()eFunctiongenerano un errore se tentato. Ad esempio,const sum = new Function('a', 'b', 'return a + b')genera un errore. - Timer
-
Le funzioni
setTimeout(),setImmediate()eclearTimeout()non sono supportate. Non vi è alcuna disposizione per differire o cedere all'interno di un'esecuzione di funzione. La funzione deve essere eseguita in modo sincrono fino al completamento. - Data e timestamp
-
Per motivi di sicurezza, non è possibile accedere ai timer ad alta risoluzione. Tutti i metodi
Dateper interrogare l'ora corrente restituiscono sempre lo stesso valore durante la durata di una singola esecuzione di funzione. Il timestamp restituito è il momento in cui la funzione ha iniziato l'esecuzione. Di conseguenza, non è possibile misurare il tempo trascorso nella vostra funzione. - Accesso al file system
-
Nessun accesso al file system. Ad esempio, non esiste un modulo
fsper l'accesso al file system come invece è presente in Node.js. - Accesso al processo
-
Non è possibile accedere al processo. Ad esempio, non esiste un oggetto globale
processper l’elaborazione dell’accesso alle informazioni come in Node.js. - Variabili di ambiente
-
Non è possibile accedere alle variabili d’ambiente. È invece possibile utilizzare KeyValueStore di CloudFront per creare un datastore centralizzato di coppie chiave-valore per le Funzioni CloudFront. KeyValueStore di CloudFront consente aggiornamenti dinamici dei dati di configurazione senza dover implementare modifiche al codice. Per ulteriori informazioni, consulta Amazon CloudFront KeyValueStore.
- Accesso alla rete
-
Non è disponibile alcun supporto per le chiamate di rete. Ad esempio, XHR, HTTP(S) e socket non sono supportati.