Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <p>Check the Console for output</p>




                function testCodeWrapper (request, items, ShipStream) {
  // Write your code here
  let myBucket = ShipStream.createBucket()
  myBucket.addItem(items[0], 1)

// Setup variables to emulate ShipStream data
const request = {
  "merchant": "acme",
  "store": "acmebrand",
  "warehouse_id": 1,
  "shipping_method": "ups_03",
  "saturday_delivery": false,
  "signature_required": "none",
  "overbox": false,
  "destination": {
    "company": "",
    "street": "",
    "city": "",
    "region": "",
    "postcode": "",
    "country": "US",
    "classification": "res"
let items = [
    "product_id": 333,
    "qty": 1,
    "unit_qty": 1,
    "product": {
      "sku": "ABC",
      "name": "ABC Widget",
      "<product_attribute_code>": "<value>"

// ShipStream embedded environmnet emulator
class Bucket {
  constructor() {
    Bucket._counter++ = Bucket._counter
    console.log('-- Created bucket '
  addItem (item, itemQty = 0, unitQty = 0) {
    if (itemQty > item.qty) {
        throw 'Preprocess Packing Solution Script Error: addItem: Unable to add '+itemQty+' of "'+item.product.sku+'" with only '+item.qty+' available.'
    console.log('-- Added item '+item.product.sku+' with qty '+itemQty+' and unit qty '+unitQty)
    if (itemQty && unitQty) {
        item.qty -= (itemQty * unitQty)
    } else if (itemQty) {
        item.qty -= itemQty;
    }else {
        item.qty -= item.qty
  setGroupSize (size) {
    console.log('-- Set bucket '' group size to '+size)
  setContainer (sku) {
    console.log('-- Set bucket '' container to '+sku)
  setLength(value) {
    console.log('-- Set bucket '' length to '+value)
  setWidth(value) {
    console.log('-- Set bucket '' length to '+value)
  setHeight(value) {
    console.log('-- Set bucket '' length to '+value)
  setContainers (skus) {
    console.log('-- Set bucket '' containers list to ('+skus.join('|')+')')
  setShippingMethod (method) {
    console.log('-- Set bucket '' shipping method to '+method)
  setPickingClass (pickingClass) {
    console.log('-- Set bucket '' picking class to '+pickingClass)
  setInfill (sku) {
    console.log('-- Set bucket '' infill to '+sku)
  setProviders (providers) {
    console.log('-- Set bucket '' length to ['+providers.join(',')+']')
  addComment (message) {
    console.log('-- Added comment to bucket '': '+message)
Bucket._counter = 0;
const ShipStream = {
  createBucket: function () {
    return new Bucket()
function print(args) { console.log(args) } // This will be recorded in the Order History

console.log('Begin script execution with '+items.length+' items:')
try {
    testCodeWrapper(request, items, ShipStream)
} catch (e) {