diff --git a/src/Data/ArrayBuffer/ArrayBuffer.js b/src/Data/ArrayBuffer/ArrayBuffer.js index b341921..30033c4 100644 --- a/src/Data/ArrayBuffer/ArrayBuffer.js +++ b/src/Data/ArrayBuffer/ArrayBuffer.js @@ -6,10 +6,10 @@ exports.emptyImpl = function empty (s) { return new ArrayBuffer(s); }; -exports.byteLength = function byteLength (a) { +export function byteLength(a) { return a.byteLength; -}; +} -exports.sliceImpl = function sliceImpl (a, s, e) { +export function sliceImpl(a, s, e) { return a.slice(s, e); -}; +} diff --git a/src/Data/ArrayBuffer/DataView.js b/src/Data/ArrayBuffer/DataView.js index 6bfee81..4c6a9db 100644 --- a/src/Data/ArrayBuffer/DataView.js +++ b/src/Data/ArrayBuffer/DataView.js @@ -3,41 +3,41 @@ // module Data.ArrayBuffer.DataView -exports.whole = function whole (b) { +export function whole(b) { return new DataView(b); -}; +} -exports.remainderImpl = function remainderImpl (b,i) { +export function remainderImpl(b, i) { return new DataView(b,i); -}; +} -exports.partImpl = function partImpl (b,i,j) { +export function partImpl(b, i, j) { return new DataView(b,i,j); -}; +} -exports.buffer = function buffer (v) { +export function buffer(v) { return v.buffer; -}; +} -exports.byteOffset = function byteOffset (v) { +export function byteOffset(v) { return v.byteOffset; -}; +} -exports.byteLength = function byteLength (v) { +export function byteLength(v) { return v.byteLength; -}; +} -exports.getterImpl = function getterImpl (data, v, o) { +export function getterImpl(data, v, o) { return ((o + data.bytesPerValue) >>> 0) <= v.byteLength ? v[data.functionName].call(v,o,data.littleEndian) : null; -}; +} -exports.setterImpl = function setterImpl (data, v, o, n) { +export function setterImpl(data, v, o, n) { if (((o + data.bytesPerValue) >>> 0) <= v.byteLength) { v[data.functionName].call(v,o,n,data.littleEndian); return true; } else { return false; } -}; +} diff --git a/src/Data/ArrayBuffer/Typed.js b/src/Data/ArrayBuffer/Typed.js index 2ab0cb6..683093b 100644 --- a/src/Data/ArrayBuffer/Typed.js +++ b/src/Data/ArrayBuffer/Typed.js @@ -2,167 +2,163 @@ // module Data.ArrayBuffer.Typed -exports.buffer = function buffer (v) { - return v.buffer; -}; +export function buffer(v) { + return v.buffer; +} -exports.byteOffset = function byteOffset (v) { - return v.byteOffset; -}; +export function byteOffset(v) { + return v.byteOffset; +} -exports.byteLength = function byteLength (v) { - return v.byteLength; -}; +export function byteLength(v) { + return v.byteLength; +} -exports.lengthImpl = function lemgthImpl (v) { - return v.length; +exports.lengthImpl = function lemgthImpl(v) { + return v.length; }; // Typed Arrays -function newArray (f) { - return function newArray_ (a,mb,mc) { +function newArray(f) { + return function newArray_(a, mb, mc) { if (mb === null) return new f(a); var l = a.byteLength; var eb = f.BYTES_PER_ELEMENT; - var off = Math.min(l, mb>>>0); + var off = Math.min(l, mb >>> 0); if (mc === null) - return new f(a,off); + return new f(a, off); var len = Math.min((l - off) / eb, mc); - return new f(a,off,len); + return new f(a, off, len); }; } -exports.newUint8ClampedArray = newArray(Uint8ClampedArray); -exports.newUint32Array = newArray(Uint32Array); -exports.newUint16Array = newArray(Uint16Array); -exports.newUint8Array = newArray(Uint8Array); -exports.newInt32Array = newArray(Int32Array); -exports.newInt16Array = newArray(Int16Array); -exports.newInt8Array = newArray(Int8Array); -exports.newFloat32Array = newArray(Float32Array); -exports.newFloat64Array = newArray(Float64Array); - +export const newUint8ClampedArray = newArray(Uint8ClampedArray); +export const newUint32Array = newArray(Uint32Array); +export const newUint16Array = newArray(Uint16Array); +export const newUint8Array = newArray(Uint8Array); +export const newInt32Array = newArray(Int32Array); +export const newInt16Array = newArray(Int16Array); +export const newInt8Array = newArray(Int8Array); +export const newFloat32Array = newArray(Float32Array); +export const newFloat64Array = newArray(Float64Array); // ------ -exports.everyImpl = function everyImpl (a,p) { - return a.every(p); -}; -exports.someImpl = function someImpl (a,p) { - return a.some(p); -}; - - -exports.fillImpl = function fillImpl (x, s, e, a) { - return a.fill(x,s,e); -}; - +export function everyImpl(a, p) { + return a.every(p); +} -exports.mapImpl = function mapImpl (a,f) { - return a.map(f); -}; +export function someImpl(a, p) { + return a.some(p); +} -exports.forEachImpl = function forEachImpl (a,f) { - a.forEach(f); -}; +export function fillImpl(x, s, e, a) { + return a.fill(x, s, e); +} -exports.filterImpl = function filterImpl (a,p) { - return a.filter(p); -}; +export function mapImpl(a, f) { + return a.map(f); +} -exports.includesImpl = function includesImpl (a,x,mo) { - return mo === null ? a.includes(x) : a.includes(x,mo); -}; +export function forEachImpl(a, f) { + a.forEach(f); +} -exports.reduceImpl = function reduceImpl (a,f,i) { - return a.reduce(f,i); -}; -exports.reduce1Impl = function reduce1Impl (a,f) { - return a.reduce(f); -}; -exports.reduceRightImpl = function reduceRightImpl (a,f,i) { - return a.reduceRight(f,i); -}; -exports.reduceRight1Impl = function reduceRight1Impl (a,f) { - return a.reduceRight(f); -}; +export function filterImpl(a, p) { + return a.filter(p); +} -exports.findImpl = function findImpl (a,f) { - return a.find(f); -}; +export function includesImpl(a, x, mo) { + return mo === null ? a.includes(x) : a.includes(x, mo); +} -exports.findIndexImpl = function findIndexImpl (a,f) { - var r = a.findIndex(f); - return r === -1 ? null : r; -}; -exports.indexOfImpl = function indexOfImpl (a,x,mo) { - var r = mo === null ? a.indexOf(x) : a.indexOf(x,mo); - return r === -1 ? null : r; -}; -exports.lastIndexOfImpl = function lastIndexOfImpl (a,x,mo) { - var r = mo === null ? a.lastIndexOf(x) : a.lastIndexOf(x,mo); - return r === -1 ? null : r; -}; +export function reduceImpl(a, f, i) { + return a.reduce(f, i); +} +export function reduce1Impl(a, f) { + return a.reduce(f); +} +export function reduceRightImpl(a, f, i) { + return a.reduceRight(f, i); +} -exports.copyWithinImpl = function copyWithinImpl (a,t,s,me) { - if (me === null) { - a.copyWithin(t,s); - } else { - a.copyWithin(t,s,me); - } -}; +export function reduceRight1Impl(a, f) { + return a.reduceRight(f); +} +export function findImpl(a, f) { + return a.find(f); +} -exports.reverseImpl = function reverseImpl (a) { - a.reverse(); -}; +export function findIndexImpl(a, f) { + var r = a.findIndex(f); + return r === -1 ? null : r; +} +export function indexOfImpl(a, x, mo) { + var r = mo === null ? a.indexOf(x) : a.indexOf(x, mo); + return r === -1 ? null : r; +} -exports.setImpl = function setImpl (a, off, b) { - a.set(b,off); -}; +export function lastIndexOfImpl(a, x, mo) { + var r = mo === null ? a.lastIndexOf(x) : a.lastIndexOf(x, mo); + return r === -1 ? null : r; +} +export function copyWithinImpl(a, t, s, me) { + if (me === null) { + a.copyWithin(t, s); + } else { + a.copyWithin(t, s, me); + } +} -exports.sliceImpl = function sliceImpl (a, s, e) { - return a.slice(s,e); -}; +export function reverseImpl(a) { + a.reverse(); +} -exports.sortImpl = function sortImpl (a) { - a.sort(); -}; +export function setImpl(a, off, b) { + a.set(b, off); +} +export function sliceImpl(a, s, e) { + return a.slice(s, e); +} -exports.subArrayImpl = function subArrayImpl (a, s, e) { - return a.subarray(s, e); -}; +export function sortImpl(a) { + a.sort(); +} +export function subArrayImpl(a, s, e) { + return a.subarray(s, e); +} -exports.toStringImpl = function toStringImpl (a) { - return a.toString(); -}; +export function toStringImpl(a) { + return a.toString(); +} -exports.joinImpl = function joinImpl (a,s) { - return a.join(s); -}; +export function joinImpl(a, s) { + return a.join(s); +} -exports.unsafeAtImpl = function(a, i) { - return a[i]; +export function unsafeAtImpl(a, i) { + return a[i]; } -exports.hasIndexImpl = function(a, i) { - return i in a; +export function hasIndexImpl(a, i) { + return i in a; } -exports.toArrayImpl = function(a) { - var l = a.length; - var ret = new Array(l); - for (var i = 0; i < l; i++) - ret[i] = a[i]; - return ret; +export function toArrayImpl(a) { + var l = a.length; + var ret = new Array(l); + for (var i = 0; i < l; i++) + ret[i] = a[i]; + return ret; }